Populating Cells with Zeroes

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

I have 8 worksheets with a customer number in column B. I would like to
populate empty cells with zeroes in all rows that have a customer number with
an empty cell.
I would also like this to repeat thru all 8 sheets.

Thanks.
 
Assuming that there are only eight sheets in the workbook.

Sub custzero()
Dim sh As Worksheet, c As Range
For Each sh In ActiveWorkbook.Sheets
lastRow = sh.Cells(Rows.Count, 2).End(xlUp).Row
For Each c In sh.Range("B2:B" & lastRow)
If c = "" Then c = 0
Next
Next
End Sub

Otherwise if there are more than eight sheets, you will
have to adjust the code.
 
Try recording a macro when you do:

Select the range to fix
edit|goto|special|blanks
type 0 and hit ctrl enter

Stop recording the macro and look at the code.

If you need help adjusting the code, post back with your question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top