-
VBA: Multiple Autofill in same column
Dear All,
As a subject it sounds easy, but I have been looking on net, couldn't find multiple autofill.
I have a database in which I need to insert Autofill for multiple coding in the same column, for first coding its easy as below:
[VBA]
Sub Journal()
Dim LR1 As Long
Dim LR2 As Long
LR1 = Sheets("Journal").Range("K" & Rows.Count).End(xlUp).Row
LR2 = Sheets("Journal").Range("J" & Rows.Count).End(xlUp).Row
Range("B3").Formula = "30020400"
Range("B3").AutoFill Range("B3:B" & LR1)
End Sub
[/VBA]
Suppose this coding is till 50th Row and for next blank cell in the same column I am using:
[VBA]
Range("B" & Rows.Count).End(xlUp).Offset(1).Formula = "60600050"
[/VBA]
I don't know how to start autofill from 51st row till the LR2.
Please help.
-
Solved:Re: Multiple Autofill in same column
I got it right, please see below for future reference:
[VBA]
Sub FillEmpty()
Dim c As Range
Dim LR As Long
Sheets("Journal").Activate
LR = Sheets("Journal").Range("C" & Rows.Count).End(xlUp).Row
For Each c In Range("B4:B" & LR)
If IsEmpty(c) Then
c.Offset(-1).Copy c
End If
Next c
End Sub
[/VBA]
You just need to call above sub in the end of your main sub.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules