Gibanabana nga oras sa pagbasa: 3 minuti
Ang mosunud nga pamaagi sa Sub nagbasa sa mga kantidad gikan sa mga cell sa kolum A sa aktibo nga worksheet, hangtod nga makit-an ang usa ka blangko nga cell. Ang mga kantidad gitipigan sa usa ka laray. Kining yano nga Excel macro nga pananglitan naghulagway sa paggamit sa:
Do Until
;Ubound
builtin (nga nagbalik sa labing taas nga indeks sa usa ka laray).' Sub procedure store values in Column A of the active Worksheet
' into an array
Sub GetCellValues()
Dim iRow As Integer ' stores the current row number
Dim dCellValues() As Double ' array to store the cell values
iRow = 1
ReDim dCellValues(1 To 10)
' Do Until loop to extract the value of each cell in column A
' of the active Worksheet, as long as the cell is not blank
Do Until IsEmpty(Cells(iRow, 1))
' Check that the dCellValues array is big enough
' If not, use ReDim to increase the size of the array by 10
If UBound(dCellValues) < iRow Then
ReDim Preserve dCellValues(1 To iRow + 9)
End If
' Store the current cell in the CellValues array
dCellValues(iRow) = Cells(iRow, 1).Value
iRow = iRow + 1
Loop
End Sub
Ang pamaagi nagtipig sa mga kantidad sa kolum A sa aktibo nga worksheet sa usa ka laray, timan-i nga:
Do Until
Gikuha ang mga kantidad sa matag cell sa kolum A sa aktibo nga worksheet, nga wala magtagad sa mga blangko nga mga cellIf UBound(dCellValues) < iRow
” nagsusi nga ang dCellValues array igo nga igo aron mahuptan ang kasayuran, kung dili, gamita ang ReDim aron madugangan ang gidak-on sa array sa 10dCellValues(iRow) = Cells(iRow, 1).Value
” Gitipigan ang kasamtangan nga cell sa CellValues arrayAng mosunud nga pamaagi sa Sub nagbasa sa mga kantidad gikan sa kolum A sa worksheet nga ginganlag "Sheet2" ug nagpahigayon mga operasyon sa aritmetika sa mga kantidad. Ang resulta nga mga kantidad giimprinta sa kolum A sa kasamtangan nga aktibo nga worksheet.
Kini nga macro naghulagway:
Do Until
;' Sub procedure to loop through the values in Column A of the Worksheet
' "Sheet2", perform arithmetic operations on each value, and write the
' result into Column A of the current Active Worksheet ("Sheet1")
Sub Transfer_ColA()
Dim i As Integer
Dim Col As Range
Dim dVal As Double
' Set the variable 'Col' to be Column A of Sheet 2
Set Col = Sheets("Sheet2").Columns("A")
i = 1
' Loop through each cell of the column 'Col' until
' a blank cell is encountered
Do Until IsEmpty(Col.Cells(i))
' Apply arithmetic operations to the value of the current cell
dVal = Col.Cells(i).Value * 2 + 1
' The command below copies the result into Column A
' of the current Active Worksheet - no need to specify
' the Worksheet name as it is the active Worksheet.
Cells(i, 1) = dVal
i = i + 1
Loop
End Sub
Magsulat kita og usa ka yano nga VBA macro nga modilaab kung ang usa ka cell sa usa ka piho nga han-ay sa atong sheet gi-update. Pananglit gusto nimong sundan ang mga pagbag-o sa kolum B (B4 hangtod B11) ug irekord ang petsa ug oras sa pagbag-o sa kolum A.
Magpadayon kita sama niini:
Developer
i-klik ang opsyon"Visual Basic
” sa pag-abli sa VBA editor. Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("B1:B10")) Is Nothing Then
Target.Range("A1:A1").Value = Now
End If
End Sub
I-save ang workbook nga adunay macros nga gipagana (pananglitan, isip .xlsm file).
Karon, matag higayon nga mag-update kami sa usa ka cell sa column B (gikan sa row 1 hangtod sa row 10), ang cell sa column A awtomatik nga magpakita sa kasamtangan nga petsa ug oras.
Ercole Palmeri
Ang Coveware ni Veeam magpadayon sa paghatag serbisyo sa pagtubag sa insidente sa cyber extortion. Magtanyag ang Coveware og mga kapabilidad sa forensics ug remediation…
Ang prediktibo nga pagmentinar nagbag-o sa sektor sa lana ug gas, nga adunay usa ka bag-o ug aktibo nga pamaagi sa pagdumala sa tanum.…
Ang UK CMA nagpagula usa ka pasidaan bahin sa pamatasan sa Big Tech sa merkado sa artipisyal nga paniktik. didto…
Ang "Green Houses" Decree, nga gimugna sa European Union aron mapalambo ang energy efficiency sa mga bilding, nagtapos sa proseso sa lehislatibo niini sa…