अंदाजे वाचन वेळ: 3 मिनुती
खालील उप प्रक्रिया सक्रिय वर्कशीटच्या स्तंभ A मधील सेलमधील मूल्ये वाचते, जोपर्यंत तो रिक्त सेलचा सामना करत नाही. मूल्ये ॲरेमध्ये संग्रहित केली जातात. हे साधे एक्सेल मॅक्रो उदाहरण याचा वापर स्पष्ट करते:
Do Until
;Ubound
बिल्टइन (जे ॲरेचा सर्वोच्च निर्देशांक मिळवते).' 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
प्रक्रिया ॲरेमध्ये सक्रिय वर्कशीटच्या स्तंभ A मध्ये मूल्ये संग्रहित करते, लक्षात ठेवा की:
Do Until
रिकाम्या सेलकडे दुर्लक्ष करून सक्रिय वर्कशीटच्या A स्तंभातील प्रत्येक सेलची मूल्ये काढतेIf UBound(dCellValues) < iRow
dCellValues ॲरे माहिती ठेवण्यासाठी पुरेसा मोठा आहे हे तपासते, नसल्यास, ॲरेचा आकार 10 ने वाढवण्यासाठी ReDim वापराdCellValues(iRow) = Cells(iRow, 1).Value
"वर्तमान सेल सेलव्हॅल्यूज ॲरेमध्ये संग्रहित करतेखालील उपप्रक्रिया "शीट2" नावाच्या वर्कशीटच्या स्तंभ A मधील मूल्ये वाचते आणि मूल्यांवर अंकगणित क्रिया करते. परिणामी मूल्ये वर्तमान सक्रिय वर्कशीटच्या स्तंभ A मध्ये मुद्रित केली जातात.
हे मॅक्रो स्पष्ट करते:
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
चला एक साधा VBA मॅक्रो लिहू जो आमच्या शीटच्या विशिष्ट श्रेणीतील सेल अद्यतनित केल्यावर सक्रिय होतो. समजा तुम्हाला स्तंभ B (B4 ते B11) मधील बदलांचा मागोवा घ्यायचा आहे आणि स्तंभ A मधील बदलाची तारीख आणि वेळ नोंदवायची आहे.
चला याप्रमाणे पुढे जाऊया:
Developer
पर्यायावर क्लिक करा "Visual Basic
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
कार्यपुस्तिका मॅक्रो सक्षम करून सेव्ह करा (उदाहरणार्थ, .xlsm फाइल म्हणून).
आता, प्रत्येक वेळी जेव्हा आपण स्तंभ B मधील सेल अद्यतनित करतो (पंक्ती 1 पासून 10 पर्यंत), स्तंभ A मधील सेल स्वयंचलितपणे वर्तमान तारीख आणि वेळ प्रदर्शित करेल.
Ercole Palmeri
Veeam द्वारे Coveware सायबर खंडणी घटना प्रतिसाद सेवा प्रदान करणे सुरू ठेवेल. Coveware फॉरेन्सिक आणि उपाय क्षमता प्रदान करेल…
वनस्पती व्यवस्थापनासाठी नाविन्यपूर्ण आणि सक्रिय दृष्टीकोनसह, भविष्यसूचक देखभाल तेल आणि वायू क्षेत्रात क्रांती घडवत आहे.…
UK CMA ने आर्टिफिशियल इंटेलिजन्स मार्केटमध्ये बिग टेकच्या वर्तनाबद्दल चेतावणी जारी केली आहे. तेथे…
इमारतींची उर्जा कार्यक्षमता वाढविण्यासाठी युरोपियन युनियनने तयार केलेल्या "ग्रीन हाऊसेस" डिक्रीने त्याची वैधानिक प्रक्रिया पूर्ण केली आहे ...