Am léitheoireachta measta: 3 nóiméad
Léann an Fo-nós imeachta seo a leanas luachanna ó chealla i gcolún A den bhileog oibre gníomhach, go dtí go dtagann sé ar chill bhán. Stóráiltear na luachanna in eagar. Léiríonn an macrashampla Excel simplí seo úsáid:
Do Until
;Ubound
builtin (a thugann an t-innéacs is airde d'eagar ar ais).' 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
Stórálann an nós imeachta na luachanna i gcolún A den bhileog oibre gníomhach in eagar, tabhair faoi deara:
Do Until
sliocht luachanna gach cille i gcolún A den bhileog oibre gníomhach, gan aird a thabhairt ar chealla bánaIf UBound(dCellValues) < iRow
” seiceálann sé go bhfuil an t-eagar dCellValues mór go leor chun an fhaisnéis a choinneáil, mura bhfuil, bain úsáid as ReDim chun méid an eagair a mhéadú faoi 10dCellValues(iRow) = Cells(iRow, 1).Value
” Stórálann sé an chill reatha san eagar Luachanna CeallaLéann an Fo-nós imeachta seo a leanas na luachanna ó cholún A den bhileog oibre darb ainm “Bileog2” agus déanann sé oibríochtaí uimhríochta ar na luachanna. Tá na luachanna mar thoradh air sin clóite i gcolún A den bhileog oibre gníomhach reatha.
Léiríonn an macra seo:
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
Scríobhaimis macra VBA simplí a lasann nuair a nuashonraítear cill i raon sonrach dár mbileog. Cuir i gcás gur mhaith leat athruithe i gcolún B (B4 go B11) a rianú agus dáta agus am an athraithe i gcolún A a thaifeadadh.
Leanaimis ar aghaidh mar seo:
Developer
cliceáil ar an rogha"Visual Basic
” chun an t-eagarthóir VBA a oscailt. 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
Sábháil an leabhar oibre le macraí cumasaithe (mar shampla, mar chomhad .xlsm).
Anois, gach uair a dhéanaimid nuashonrú ar chill i gcolún B (ó shraith 1 go ró 10), taispeánfaidh an chill i gcolún A an dáta agus an t-am reatha go huathoibríoch.
Ercole Palmeri
Rinneadh oibríocht oftalmoplasty ag baint úsáide as breathnóir tráchtála Apple Vision Pro ag an Catania Polyclinic…
Má dhéantar mionscileanna mótair a fhorbairt trí dhathú, ullmhaítear leanaí le haghaidh scileanna níos casta mar an scríbhneoireacht. Le dathú…
Is fíorchumhacht eacnamaíoch dhomhanda í an earnáil chabhlaigh, atá tar éis dul i dtreo margadh 150 billiún...
Dé Luain seo caite, d'fhógair an Financial Times comhaontú le OpenAI. Ceadaíonn FT a iriseoireacht den scoth…