Iye akoko kika: 3 iṣẹju
Ilana Sub atẹle yii ka awọn iye lati awọn sẹẹli ni iwe A ti iwe iṣẹ ti nṣiṣe lọwọ, titi yoo fi pade sẹẹli ofo kan. Awọn iye ti wa ni fipamọ ni ohun orun. Apeere Makiro Excel ti o rọrun yii ṣe afihan lilo ti:
Do Until
;Ubound
builtin (eyi ti o pada ga atọka ti ohun orun).' 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
Ilana naa tọju awọn iye ni iwe A ti iwe iṣẹ ti nṣiṣe lọwọ ni ọna kan, ṣe akiyesi pe:
Do Until
yọkuro awọn iye ti sẹẹli kọọkan ni iwe A ti iwe iṣẹ ti nṣiṣe lọwọ, kọju awọn sẹẹli ofoIf UBound(dCellValues) < iRow
"Ṣayẹwo pe dCellValues ti o tobi to lati di alaye naa mu, ti kii ba ṣe bẹ, lo ReDim lati mu iwọn titobi pọ si nipasẹ 10dCellValues(iRow) = Cells(iRow, 1).Value
"Ṣipamọ sẹẹli lọwọlọwọ ni titobi CellValuesIlana Sub atẹle yii ka awọn iye lati iwe A ti iwe iṣẹ ti a npè ni “Sheet2” ati ṣe awọn iṣẹ ṣiṣe iṣiro lori awọn iye. Awọn iye abajade ti wa ni titẹ ni iwe A ti iwe iṣẹ ṣiṣe lọwọlọwọ.
Makiro yii ṣapejuwe:
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
Jẹ ki a kọ Makiro VBA ti o rọrun ti o njo nigbati sẹẹli kan ni iwọn kan pato ti dì wa ti ni imudojuiwọn. Ṣebi o fẹ lati tọpa awọn ayipada ninu iwe B (B4 si B11) ati ṣe igbasilẹ ọjọ ati akoko iyipada ni iwe A.
Jẹ ki a tẹsiwaju bi eleyi:
Developer
tẹ lori aṣayan "Visual Basic
”lati ṣii olootu 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
Ṣafipamọ iwe iṣẹ pẹlu awọn macros ṣiṣẹ (fun apẹẹrẹ, bi faili .xlsm kan).
Bayi, ni gbogbo igba ti a ba ṣe imudojuiwọn sẹẹli kan ni iwe B (lati ila 1 si laini 10), sẹẹli ti o wa ninu iwe A yoo ṣe afihan ọjọ ati akoko lọwọlọwọ laifọwọyi.
Ercole Palmeri
Coveware nipasẹ Veeam yoo tẹsiwaju lati pese awọn iṣẹ esi iṣẹlẹ ikọlu cyber. Coveware yoo funni ni awọn oniwadi ati awọn agbara atunṣe…
Itọju isọtẹlẹ jẹ iyipada ti eka epo & gaasi, pẹlu imotuntun ati ọna imudani si iṣakoso ọgbin.…
UK CMA ti ṣe ikilọ kan nipa ihuwasi Big Tech ni ọja itetisi atọwọda. Nibẹ…
Ilana “Case Green”, ti a ṣe agbekalẹ nipasẹ European Union lati jẹki imunadoko agbara ti awọn ile, ti pari ilana isofin rẹ pẹlu…