Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Format cells in web query (leading zeroes) Kathy Excel Discussion (Misc queries) 5 October 2nd 07 02:26 PM
Adding leading zeroes to selected alphanumeric cells [email protected] Excel Programming 1 September 26th 07 04:02 PM
A fixed field format needs fronting zeroes for each cells value. CommerceMary Excel Worksheet Functions 8 July 25th 07 08:44 PM
How do I format data cells in Excel to keep leading zeroes? LennyD Setting up and Configuration of Excel 2 December 15th 04 10:42 PM
Delete cells in row A with just zeroes Tim Zych[_2_] Excel Programming 0 July 16th 03 10:31 PM


All times are GMT +1. The time now is 05:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"