Lub sijhawm nyeem ntawv kwv yees: 3 minuti
Cov txheej txheem Sub hauv qab no nyeem cov txiaj ntsig ntawm cov hlwb hauv kab A ntawm daim ntawv ua haujlwm nquag, kom txog rau thaum nws ntsib lub xov tooj dawb. Cov nqi khaws cia hauv ib qho array. Qhov yooj yim Excel macro piv txwv qhia txog kev siv:
Do Until
;Ubound
builtin (uas rov qab qhov ntsuas siab tshaj plaws ntawm ib qho array).' 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
Cov txheej txheem khaws cov txiaj ntsig hauv kab A ntawm daim ntawv ua haujlwm nquag hauv ib qho array, nco ntsoov tias:
Do Until
rho tawm cov txiaj ntsig ntawm txhua lub xov tooj hauv kab A ntawm daim ntawv ua haujlwm nquag, tsis quav ntsej cov hlwbIf UBound(dCellValues) < iRow
” kuaj xyuas tias dCellValues array loj txaus los tuav cov ntaub ntawv, yog tias tsis yog, siv ReDim kom nce qhov loj ntawm array los ntawm 10dCellValues(iRow) = Cells(iRow, 1).Value
” Khaws cov xovtooj tam sim no hauv CellValues arrayCov txheej txheem Sub hauv qab no nyeem cov txiaj ntsig ntawm kab A ntawm daim ntawv ua haujlwm hu ua "Sheet2" thiab ua cov lej lej ntawm cov nqi. Cov txiaj ntsig tau raug luam tawm hauv kab A ntawm daim ntawv ua haujlwm tam sim no.
Qhov no macro qhia txog:
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
Cia peb sau ib qho yooj yim VBA macro uas tua hluav taws thaum lub xov tooj ntawm tes hauv ib qho tshwj xeeb ntawm peb daim ntawv hloov tshiab. Piv txwv tias koj xav taug qab cov kev hloov pauv hauv kab B (B4 txog B11) thiab sau hnub thiab sijhawm ntawm kev hloov pauv hauv kab A.
Cia peb ua li no:
Developer
nyem rau ntawm qhov kev xaiv "Visual Basic
"los qhib 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
Txuag phau ntawv ua haujlwm nrog macros enabled (piv txwv li, ua cov ntaub ntawv .xlsm).
Tam sim no, txhua zaus peb hloov kho lub xov tooj ntawm kab ntawv B (los ntawm kab 1 txog kab 10), lub xov tooj ntawm tes hauv kab A yuav cia li tso saib hnub thiab sijhawm tam sim no.
Ercole Palmeri
Kev lag luam ophthalmoplasty siv Apple Vision Pro coj mus muag saib tau ua ntawm Catania Polyclinic…
Tsim kom muaj kev txawj tsav tsheb zoo los ntawm kev pleev xim npaj cov menyuam yaus rau kev txawj ntse ntau dua li kev sau ntawv. Rau xim…
Kev lag luam naval yog lub zog kev lag luam thoob ntiaj teb tiag tiag, uas tau taug kev mus rau 150 billion kev lag luam ...
Hnub Monday dhau los, Lub Sijhawm Nyiaj Txiag tau tshaj tawm kev pom zoo nrog OpenAI. FT tso cai nws cov ntawv xov xwm thoob ntiaj teb…