Filldown formula to bottom of data rows

Lola223

New Member
Joined
Jan 18, 2022
Messages
26
Office Version
  1. 2010
Hi All,

I am trying to filldown a couple of formulas that I have in columns W and X based on the last row of data in column A of that worksheet. The code works if I have the relevant sheet activated at the time but not when I have another sheet active.


VBA Code:
Sub FillFormulas()

Dim Last_row As Long
Dim sh4 As Worksheet

Set sh4 = workbooks("Test.xlsm").Worksheets("Test Data")

Last_row = sh4.Cells(Rows.Count, 1).End(xlUp).Row
Range("W2:X" & Last_row).Filldown
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
The last line is missing the worksheet object:

Code:
sh4.Range("W2:X" & Last_row).Filldown
 
Upvote 0
Solution

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

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