Ignore Autofill when there's nothing to fill

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I currently autofill on mulitple spreatsheets in a workbook. My problem is,
that if there is nothing to fill in a particular sheet (the sheets are auto
populated by another macro) then the macro gives me an error message.

My question is, what can I add to the code below for it to skip the autofill
if there is nothing to fill?

With Worksheets("Complete PVC")
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("A2").AutoFill Destination:=.Range("A2:A" & LastRow),
Type:=xlFillDefault
End With

Thanks in advance for any help anyone can offer.

Anita
 
Hi Anita,
use a check for ISEMPTY as in:

If NOT IsEmpty(Range("A2")) Then
.Range("A2").AutoFill Destination:=.Range("A2:A" & LastRow), _
Type:=xlFillDefault
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top