Macro that stop when it finds a blank cell in Row A

fishingsantafe

New Member
Joined
Sep 1, 2005
Messages
13
Hi

I would like to write a macro that would copy formula in B2 and then copy it down row B until it finds that a cell in row A is blank. This report changes all the time so I never know how much data is in row A. So I want the macro to stop copying the formula down row B when it finds a blank cell in Row A.

I tried the Do Until but it did not do anything unless I had something wrong. I recorded the intial copy B2 to B3 to see what it wrote. I tried an if statement also.

Any help would be apprieciated. I have Excel 2003.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Code:
Sub formulafill()
LR = Cells(Rows.Count, "A").End(xlup).row
Range("B2:B" & LR).FillDown
End Sub
 
Upvote 0
Hi
Paste the following codes in the macro window ( Alt F8)

Code:
x = Cells(Rows.Count, 1).End(xlUp).Row
a = "B2:B" & x
Cells(2, 2).Select
    Selection.AutoFill Destination:=Range(a), Type:=xlFillDefault
run the macro
Ravi
 
Upvote 0
you know you can just double click the fill handle to do this, the fill handle is the little black square at the bottom right of the active cell,

HTH
 
Upvote 0
Thanks for responding

Thanks Shippey121 I did nit realize the auto fill bar had this function,

Thanks Ravishankar and jonmo1 for the code. I will use them in the future and keep it for examples
 
Upvote 0

Forum statistics

Threads
1,214,621
Messages
6,120,563
Members
448,972
Latest member
Shantanu2024

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