find blank cell and place a zero (0)

Dummy Excel

Well-known Member
Joined
Sep 21, 2005
Messages
1,004
Office Version
  1. 2019
  2. 2010
  3. 2007
Platform
  1. Windows
Morning All,

I have a spreadsheet which every now and then I need to add a new row (for a new store), although adding a new row leaves blank cells - I have recorded a macro to fill the blank cells, although was wondering if there is a simplier way of writing the code.

my code is:
Code:
    Range("D8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("e8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("f8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("g8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("h8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("i8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("j8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("k8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("l8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("m8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("n8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("o8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("p8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("q8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("r8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"
    Range("s8").End(xlDown).Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "0"

thanks
Sam
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hello Sam,
You can replace all those lines of code with this single line:
Code:
Range("D8").End(xlDown)(2).Resize(, 16).Value = "0"

Hope it helps.
 
Upvote 0
thanks this works great
two questions though about the formula:

1) what does (2) mean?
2) what does resize do?

thanks
Sam
 
Upvote 0
I think I worked it out

End(xlDown)(2) is the same as End(xlDown).Offset(1, 0)?

Resize(, 16) places a 0 16 columns across?
 
Upvote 0

Forum statistics

Threads
1,215,516
Messages
6,125,284
Members
449,218
Latest member
Excel Master

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