IF Not ISEmpty Autofill problem

RaydenUK

Board Regular
Joined
Mar 25, 2014
Messages
74
I have a macro that will autofill column C with the contents of "C1" to the last used row from column A. This code works great unless row 1 is the only row. That is why I used "If Not IsEmpty("A2") Then" because I wanted it to recognize that if "A2" is empty then do not autofill. When i use this code on only 1 row then i get the error "1004: Autofil method of range class failed". Can anyone help me out with this code? Thank you.

Code:
Sub UsedRange()

    Dim lastrow As Long
    
   If Not IsEmpty("A2") Then
       lastrow = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row
       Range("C1").AutoFill Range("C1:C" & lastrow), xlFillCopy
   End If


End Sub
 
HA! It Works! i was putting your line of code in the wrong place. Like I said I'm still new at it. This will help me out tremendously. Thank you for your patience and all your help.
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,215,376
Messages
6,124,594
Members
449,174
Latest member
chandan4057

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