स्थिति:
सेल "A1" पर मेरा मान "1" है
सेल "A10" पर मेरे पास "2" का मान है
सेल "A20" पर मेरा मान "3" है
सेल "ए 30" पर मेरे पास "4" मान है
मैं एक्सेल वीबीए के साथ क्या करना चाहता हूं:
A1 और A10 के बीच खाली सेल होते हैं। मैं चाहता हूं कि A2:A9 A10 के मान से भरा हो, जिसका अर्थ है "2"।
A10 और A20 के बीच खाली सेल होते हैं। मैं चाहता हूं कि A11:19 A20 के मान से भरा हो, जिसका अर्थ है "3"।
समस्या यह है कि A1 से A30 तक की सीमा निश्चित नहीं है। मैं उन कोशिकाओं के लिए पूरी पंक्ति खोजना चाहता हूं जो खाली नहीं हैं और उनके बीच की कोशिकाओं को ऊपरी सेल से भरना है जो भरा हुआ है।
संपादित करें:
अधिक व्याख्या करने के लिए, मेरे पास एक तालिका के साथ एक एक्सेस डेटाबेस है जो तिथियों से भरा है और एक तालिका जो संख्याओं से भरी हुई है।
मैं एक एक्सेल शीट पर एक रिपोर्ट बनाना चाहता हूं।
Dim Daten As Variant
Daten = Array(rs!DatumJMinus8Monate, rs!DatumJ, rs!DatumI, rs!DatumH, rs!DatumG, rs!DatumF, rs!DatumE, rs!DatumD, rs!DatumC, rs!DatumB, rs!DatumA, rs!DatumA4Monate)
Dim Bedarfe As Variant
Bedarfe = Array(rs!BedarfJ8Monate, rs!BedarfJ, rs!BedarfI, rs!BedarfH, rs!BedarfG, rs!BedarfF, rs!Bedarfe, rs!BedarfD, rs!BedarfC, rs!BedarfB, rs!BedarfA, rs!BedarfA, "")
Dim neuereintrag As Boolean
bedarfindex = 0
For Each element In Daten
i = 7
For jahre = 1 To 10
If Cells(1, i + 1) = Year(element) Then
For monate = 1 To 12
If Cells(2, i + monate) = Month(element) Then
Cells(zeile, i + monate) = Bedarfe(bedarfindex)
Cells(zeile, i + monate).Font.Bold = True
bedarfindex = bedarfindex + 1
neuereintrag = True
ElseIf IsEmpty(Cells(zeile, i + monate)) Or neuereintrag = True Then
Cells(zeile, i + monate) = Bedarfe(bedarfindex)
neuereintrag = False
End If
Next monate
End If
i = i + 12
Next jahre
Next element
चित्र में लाल घेरे में संख्याओं को हटाना है।
2 जवाब
नीचे से ऊपर की ओर काम करने के रास्ते पर:
Sub FillUp()
Dim N As Long
Dim i As Long
N = Cells(Rows.Count, "A").End(xlUp).Row
For i = N - 1 To 1 Step -1
If Cells(i, 1).Value = "" Then Cells(i, 1).Value = Cells(i + 1, 1).Value
Next i
End Sub
Sub FillUp() Dim N As Long Dim i As Long N = Cells(1, Columns.Count).End(xlToLeft).Column For i = N - 1 To 1 Step -1 If Cells(1, i).Value = "" Then Cells(1, i).Value = Cells(1, i + 1).Value Next i End Sub
शायद कुछ ऐसा। इसे थोड़ा काम करने की आवश्यकता है क्योंकि यह विफल हो जाएगा यदि दो मान एक दूसरे के बगल में हैं, या कॉलम 1 में कोई मान नहीं है।
Sub AutoFill()
Dim rCell1 As Range, rCell2 As Range
With ThisWorkbook.Worksheets("Sheet1")
'Find the last column containing data, set both references to this
'so the Do While doesn't fall over on the first loop.
Set rCell2 = .Cells(1, .Columns.Count).End(xlToLeft) '1 is the row number it's looking at.
Set rCell1 = rCell2
'Find next cell to the left containing data and fill between these two columns.
Do While rCell1.Column <> 1
Set rCell1 = rCell2.End(xlToLeft)
.Range(rCell1, rCell2.Offset(, -1)).FillRight
Set rCell2 = rCell1
Loop
End With
End Sub
नए सवाल
vba
अनुप्रयोगों के लिए विजुअल बेसिक (VBA) मैक्रो लिखने के लिए एक इवेंट-संचालित, ऑब्जेक्ट-ओरिएंटेड प्रोग्रामिंग भाषा है, जिसका उपयोग पूरे ऑफिस सूट के साथ-साथ अन्य अनुप्रयोगों के लिए भी किया जाता है। VBA VB.NET, या VBS के बराबर नहीं है; यदि आप Visual Studio उपयोग [vb.net] में काम कर रहे हैं। यदि आपका प्रश्न विशेष रूप से किसी एमएस ऑफिस एप्लिकेशन को प्रोग्रामिंग करने के बारे में है, तो उपयुक्त टैग का भी उपयोग करें: [एक्सेल], [एमएस-एक्सेस], [एमएस-वर्ड], [आउटलुक], या [एमएस-प्रोजेक्ट]।
code
जोड़ें।On the Cell "A30" i have the value "4"
- क्या यह मान 1048576 / 65536 पंक्ति में कॉपी हो जाता है?