Oge agụpụtara echere: 3 minuti
Usoro Sub na-esonụ na-agụ ụkpụrụ sitere na sel na kọlụm A nke akwụkwọ ọrụ na-arụ ọrụ, ruo mgbe ọ zutere cell oghere. A na-echekwa ụkpụrụ ndị ahụ n'usoro. Ihe atụ macro Excel a dị mfe na-egosi iji:
Do Until
;Ubound
builtin (nke na-eweghachi ndepụta kachasị elu nke n'usoro).' 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
Usoro a na-echekwa ụkpụrụ na kọlụm A nke akwụkwọ ọrụ na-arụ ọrụ n'usoro, rịba ama na:
Do Until
na-ewepụta ụkpụrụ nke cell ọ bụla na kọlụm A nke akwụkwọ ọrụ na-arụ ọrụ, na-eleghara sel oghere anyaIf UBound(dCellValues) < iRow
" na-enyocha na dCellValues array buru ibu iji jide ozi ahụ, ọ bụrụ na ọ bụghị, jiri ReDim mee ka nhazi ahụ dịkwuo 10.dCellValues(iRow) = Cells(iRow, 1).Value
" Na-echekwa cell ugbu a na CellValue n'usoroUsoro nke a na-esote na-agụ ụkpụrụ sitere na kọlụm A nke akwụkwọ ọrụ akpọrọ "Sheet2" ma na-arụ ọrụ mgbakọ na mwepụ na ụkpụrụ. A na-ebipụta ụkpụrụ ndị si na kọlụm A nke akwụkwọ ọrụ na-arụ ọrụ ugbu a.
Nke a macro na-egosi:
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
Ka anyị dee nnukwu VBA dị mfe nke na-ere ọkụ mgbe emelitere cell n'ụdị mpempe akwụkwọ anyị. Ka e were ya na ịchọrọ soro mgbanwe dị na kọlụm B (B4 ruo B11) wee dekọọ ụbọchị na oge mgbanwe na kọlụm A.
Ka anyị gaba n'ihu dịka nke a:
Developer
pịa nhọrọ"Visual Basic
” ka imepe VBA editọ. 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
Chekwaa akwụkwọ ọrụ site na macro agbanyere (dịka ọmụmaatụ, dị ka faịlụ .xlsm).
Ugbu a, oge ọ bụla anyị na-emelite cell na kọlụm B (site na ahịrị 1 ruo n'ahịrị 10), cell na kọlụm A ga-egosipụta ụbọchị na oge dị ugbu a ozugbo.
Ercole Palmeri
Coveware nke Veeam ga-aga n'ihu na-enye ọrụ nzaghachi ihe omume cyber. Coveware ga-enye forensics na ike mmezi…
Ndozi amụma na-agbanwe mpaghara mmanụ & gas, na-enwe usoro ọhụrụ na ngwa ngwa maka njikwa ihe ọkụkụ.…
UK CMA enyela ịdọ aka ná ntị gbasara omume Big Tech na ahịa ọgụgụ isi. Ebe ahụ…
Iwu “Case Green”, nke European Union chepụtara iji kwalite nrụpụta ike nke ụlọ, ejirila…