VBA fill series if data present otherwise proceed to next

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
929
Office Version
  1. 365
Platform
  1. Windows
I have a report that fills in data from B10 to N10 and down. the amount of rows that get filled can vary and sometimes it is only 1 row of data B10:N10.

I like to Number these rows in column A starting with A10 as "1".

I want to modify my VBA code to number the rows if there is more than 1 row of data (basically if there is data in B11).

How would I modify this code?

If there is data in B11 fill series to end, if not proceed to the next part of the code.

Thank you to anyone who can help!

VBA Code:
    Range("A10").Select
    ActiveCell.FormulaR1C1 = "1"

'Here is the part I need modified:
        Range("A10").AutoFill Destination:=Range("A10:A" & Cells(Rows.Count, "B").End(xlUp).Row), Type:=xlFillSeries
Calculate
    Range("A1").Select

Sheets("DATA").Select

If (ActiveSheet.AutoFilterMode And ActiveSheet.FilterMode) Or ActiveSheet.FilterMode Then
  ActiveSheet.ShowAllData
  End If

Sheets("Weekly").Select

Application.ScreenUpdating = True

MsgBox "Weekly Report Complete"

End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Maybe change the line you want to modify to this:
VBA Code:
If Not IsEmpty(Range("B11")) Then
    Range("A10").AutoFill Destination:=Range("A10:A" & Cells(Rows.Count, "B").End(xlUp).Row), Type:=xlFillSeries
End If
 
Upvote 0
Solution
Maybe change the line you want to modify to this:
VBA Code:
If Not IsEmpty(Range("B11")) Then
    Range("A10").AutoFill Destination:=Range("A10:A" & Cells(Rows.Count, "B").End(xlUp).Row), Type:=xlFillSeries
End If
This is perfect, thank you!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top