Tombanana ny fotoana famakiana: 3 minuti
Ity dingana manaraka ity dia mamaky ny soatoavina avy amin'ny sela ao amin'ny tsanganana A amin'ny takelaka miasa, mandra-pahatongany amin'ny sela banga. Ny soatoavina dia voatahiry ao anaty lasy. Ity ohatra macro Excel tsotra ity dia mampiseho ny fampiasana ny:
Do Until
;Ubound
builtin (izay mamerina ny mari-pamantarana ambony indrindra amin'ny 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
Ny fomba fiasa dia mitahiry ny soatoavina ao amin'ny tsanganana A amin'ny worksheet mavitrika amin'ny array, mariho fa:
Do Until
maka ny sandan'ny sela tsirairay ao amin'ny tsanganana A amin'ny takelaka miasa, tsy miraharaha ny sela bangaIf UBound(dCellValues) < iRow
” Manamarina fa ny dCellValues array dia ampy hitazonana ny fampahalalana, raha tsy izany dia ampiasao ny ReDim hampitombo ny haben'ny array amin'ny 10dCellValues(iRow) = Cells(iRow, 1).Value
” Mitahiry ny sela ankehitriny ao amin'ny laharan'ny CellValuesIty dingana manaraka ity dia mamaky ny soatoavina avy amin'ny tsanganana A amin'ny takelaka antsoina hoe "Sheet2" ary manao asa arithmetika amin'ny soatoavina. Ny sanda vokarina dia atao pirinty ao amin'ny tsanganana A amin'ny takelaka miasa ankehitriny.
Ity macro ity dia mampiseho:
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
Andao hanoratra macro VBA tsotra izay mirehitra rehefa misy sela ao anatin'ny faritra voafaritra amin'ny takelaka misy antsika nohavaozina. Eritrereto hoe te hanara-maso ny fiovana ao amin'ny tsanganana B (B4 ka hatramin'ny B11) ianao ary raketinao ny daty sy ny fotoanan'ny fiovana ao amin'ny tsanganana A.
Andao hirosoana toy izao:
Developer
tsindrio ny safidy "Visual Basic
” hanokafana ny tonian-dahatsoratra 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
Tehirizo ny bokikely miaraka amin'ny macros alefa (ohatra, ho rakitra .xlsm).
Ankehitriny, isaky ny manavao sela iray ao amin'ny tsanganana B isika (avy amin'ny laharana 1 ka hatramin'ny andalana 10), ny sela ao amin'ny tsanganana A dia hampiseho ho azy ny daty sy ora ankehitriny.
Ercole Palmeri
Nisy fandidiana ophthalmoplasty tamin'ny alàlan'ny mpijery ara-barotra Apple Vision Pro natao tao amin'ny Catania Polyclinic…
Ny fampivelarana ny fahaiza-manao maotera tsara amin'ny alalan'ny fandokoana dia manomana ny ankizy amin'ny fahaiza-manao sarotra kokoa toy ny fanoratana. Loko…
Ny sehatry ny tafika an-dranomasina dia tena hery ara-toekarena manerantany, izay nivezivezy nankany amin'ny tsena 150 miliara...
Ny alatsinainy lasa teo, nanambara fifanarahana tamin'ny OpenAI ny Financial Times. Ny FT dia manome alalana ny asa fanaovan-gazety manerantany…