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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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,215,543
Messages
6,125,429
Members
449,223
Latest member
Narrian

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