Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Format cells in web query (leading zeroes) | Excel Discussion (Misc queries) | |||
Adding leading zeroes to selected alphanumeric cells | Excel Programming | |||
A fixed field format needs fronting zeroes for each cells value. | Excel Worksheet Functions | |||
How do I format data cells in Excel to keep leading zeroes? | Setting up and Configuration of Excel | |||
Delete cells in row A with just zeroes | Excel Programming |