Help with Variable Use

Blauv

Board Regular
Joined
Mar 26, 2010
Messages
126
I have the below variable I am using.

Code:
Dim SetFormulasLeipsic As Long    SetFormulasLeipsic = Sheets("DataB1toDUKE").Range("A" & Rows.Count).End(xlUp).Row
    
    
Range("A2:Y2").AutoFill Destination:=Range("A2:Y2" & SetFormulasLeipsic)

When I F8 through it SetFormulasLeipsic captures the correct row count. (459)
The problem comes on the AutoFill.


For some stupid reason it is adding 200 to i, and fills down to 2459......


What the heck am I missing here?

As always your help is greatly appreciated.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
This:

Code:
Range("A2:Y2").AutoFill Destination:=Range("A2:Y2" & SetFormulasLeipsic)

says:

Code:
Range("A2:Y2").AutoFill Destination:=Range("A2:Y2459")

because the varible is just concatented to the "A2:Y2" so you just need to use "A2:Y". Miss the 2. Also qualify your ranges with the sheet name. You have for your last row variable but not when it comes to the autofill.
 
Upvote 0
Try:
Rich (BB code):
Range("A2:Y2").Autofill Destination:=Range("A2:Y" & SetFormulasLeipsic)
Consider:
Rich (BB code):
Msgbox "Hello"
Msgbox "Hello" & 2
Msgbox "Hello2" & 2
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

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