Te taima panui: 3 minuti
Ko te tikanga iti e whai ake nei ka panui i nga uara mai i nga pūtau kei te pou A o te raumahi hohe, tae noa ki te tutaki ki tetahi pūtau tuwhera. Ka penapena nga uara ki roto i te huinga. Ko tenei tauira tonotono Excel ngawari e whakaatu ana i te whakamahinga o:
Do Until
;Ubound
builtin (e whakahoki mai ana i te taupū teitei o te huānga).' 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
Ko te tikanga ka pupuri i nga uara ki te pou A o te raumahi hohe i roto i te huranga, me mahara:
Do Until
ka tango i nga uara o ia pūtau kei te tīwae A o te pepa mahi hohe, me te kore e aro ki nga pūtau pāteaIf UBound(dCellValues) < iRow
" ka tirohia he nui te huinga dCellValues hei pupuri i nga korero, ki te kore, whakamahia te ReDim hei whakanui ake i te rahi o te huinga ma te 10dCellValues(iRow) = Cells(iRow, 1).Value
” Pupuri ana i te pūtau o nāianei ki te huānga CellValuesKo te tikanga iti e whai ake nei ka panui i nga uara mai i te pou A o te raumahi kua whakaingoatia ko “Sheet2” me te mahi taurangi i runga i nga uara. Ko nga uara ka puta ka taia ki te pou A o te raumahi hohe o naianei.
Ko tenei tonotono e whakaatu ana:
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
Me tuhi he tonotono VBA ngawari e ka ana ina whakahōuhia he pūtau kei roto i te awhe motuhake o to tatou rau. Mehemea kei te pirangi koe ki te whai i nga huringa i te pou B (B4 ki B11) ka tuhi i te ra me te wa o te huringa ki te pou A.
Kia penei ta tatou haere:
Developer
pāwhiritia te kōwhiringa "Visual Basic
” ki te whakatuwhera i te ētita 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
Tiakina te pukamahi me nga tonotono kua whakahohea (hei tauira, hei konae .xlsm).
Inaianei, i nga wa katoa ka whakahōuhia he pūtau i te tīwae B (mai i te rarangi 1 ki te rarangi 10), ka whakaatu aunoa te pūtau o te tīwae A i te rā me te wā o nāianei.
Ercole Palmeri
Ka whakarato tonu a Coveware na Veeam i nga ratonga whakautu mai i nga aitua. Ka tukuna e Coveware nga mahi whakawai me te whakatikatika…
Ko te tiaki matapae kei te huri haere i te waahanga hinu me te hau, me te huarahi auaha me te kaha ki te whakahaere tipu.…
Kua tukuna e te UK CMA tetahi whakatupato mo te whanonga a Big Tech i te maakete mohio. I reira…
Ko te Whakatau "Nga Whare Kaariki", i hangaia e te Kotahitanga o Europi hei whakarei ake i te kaha o te kaha o nga whare, kua mutu tana mahi ture me te…