Isikhathi sokufunda esilinganiselwe: 3 imizuzu
Inqubo Encane elandelayo ifunda amanani kumaseli akukholomu A yekhasi lokusebenzela elisebenzayo, ize ihlangabezane neseli elingenalutho. Amanani agcinwa ohlwini. Lesi sibonelo esilula se-Excel sibonisa ukusetshenziswa kwalokhu:
Do Until
;Ubound
buildin (ebuyisela inkomba ephezulu kakhulu yohlu).' 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
Inqubo igcina amanani kukholamu A yekhasi lokusebenzela elisebenzayo ngohlelo, qaphela ukuthi:
Do Until
ikhipha amanani eseli ngalinye kukholomu A yekhasi lokusebenzela elisebenzayo, indiva amaseli angenaluthoIf UBound(dCellValues) < iRow
” ihlola ukuthi uhlu lwe-dCellValues likhulu ngokwanele ukubamba ulwazi, uma kungenjalo, sebenzisa i-ReDim ukuze ukhuphule usayizi wamalungu afanayo ngo-10.dCellValues(iRow) = Cells(iRow, 1).Value
” Igcina iseli yamanje ohlwini lwama-CellValuesInqubo Engaphansi elandelayo ifunda amanani asuka kukholomu A yekhasi lokusebenzela eliqanjwe “Ishidi2” futhi lenza imisebenzi yezibalo kumanani. Amanani angumphumela aphrintwa kukholomu A yekhasi lokusebenzela elisebenzayo lamanje.
Le macro ibonisa:
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
Masibhale i-VBA macro elula evutha lapho iseli kuhlu oluthile lweshidi lethu libuyekezwa. Ake sithi ufuna ukulandelela izinguquko kukholamu B (B4 kuye ku-B11) futhi urekhode usuku nesikhathi soshintsho kukholamu A.
Masiqhubeke kanje:
Developer
chofoza inketho "Visual Basic
” ukuze uvule umhleli we-VBA. 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
Londoloza incwadi yokusebenza ngamamakhro avuliwe (isibonelo, njengefayela le-.xlsm).
Manje, ngaso sonke isikhathi lapho sibuyekeza iseli kukholamu B (kusuka kumugqa 1 kuye kumugqa 10), iseli elikukholomu A lizobonisa ngokuzenzakalelayo idethi yamanje nesikhathi.
Ercole Palmeri
I-Coveware ye-Veeam izoqhubeka nokuhlinzeka ngezinsizakalo zokuphendula izigameko zokuntshontshwa kwe-inthanethi. I-Coveware izohlinzeka ngama-forensics kanye nekhono lokulungisa…
Ukulungiswa okuqagelayo kuguqula umkhakha kawoyela negesi, ngendlela emisha nesebenzayo yokuphatha izitshalo.…
I-CMA yase-UK ikhiphe isexwayiso mayelana nokuziphatha kwe-Big Tech emakethe yezobunhloli bokwenziwa. Lapho…
Isinqumo esithi "Case Green", esakhiwe yi-European Union ukuze kuthuthukiswe ukusebenza kahle kwamandla ezakhiwo, siphothule inqubo yaso yomthetho ngokuthi...