![]() |
Populating Cells with Zeroes
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. -- Bob |
Populating Cells with Zeroes
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. "Bob" wrote: 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. -- Bob |
Populating Cells with Zeroes
Thanks. However I forgot to add that I will need zeros in empty cells from D
thru BK. -- Bob "JLGWhiz" wrote: 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. "Bob" wrote: 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. -- Bob |
Populating Cells with Zeroes
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. Bob wrote: 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. -- Bob -- Dave Peterson |
All times are GMT +1. The time now is 03:52 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com