How to use filldown with variables

stephicohu

New Member
Joined
Jan 27, 2023
Messages
26
Office Version
  1. 365
Platform
  1. MacOS
What I am doing is to fill down the equation on AG3. What I want to do is to fill down 4 rows to AG7. I wan to use variables because I have many equations in different columns to down fill. The code is below:

Sub Test2()

Dim Sumnum As Integer
Dim Num1 As Integer
Dim BottomNum As Integer

Sumnum = 0
Num1 = 0
BottomNum = 0

Sumnum = 33
Num1 = 3
BottomNum = 7

Range(Cells(Sumnum, 3), Cells(Sumnum, 7)).FillDown



Range("V25").Select

End Sub

What am I doing wrong?

Thanks....

Stephanie
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
How about
Excel Formula:
Range(Cells(Num1, Sumnum), Cells(BottomNum, Sumnum)).FillDown
 
Upvote 0
Fluff has already provided the fix. Just some background. The syntax is:
Range(Cells(FirstRow, ColNo), Cells(LastRow, ColNo)).FillDown
If you actually use the words Row & Col as part of the variable names you are far less likely to get confused.
 
Upvote 0
Fluff has already provided the fix. Just some background. The syntax is:
Range(Cells(FirstRow, ColNo), Cells(LastRow, ColNo)).FillDown
If you actually use the words Row & Col as part of the variable names you are far less likely to get confused.
That is correct.... I found the problem at 1:00 am PST this morning. I'd reversed the row and col. I am doing that now using row and column in the variable.

Thanks

Stephanie....
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,525
Members
449,088
Latest member
RandomExceller01

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