Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / October 2006

Tip: Looking for answers? Try searching our database.

Automatically fill empty cell with default value i.e. 0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
altric - 10 Oct 2006 07:48 GMT
Hi everyone,

Example:

Name     Qty        Cost          Total
ABC        10         1.00          10.00
BC                                         0.00
AC          10         2.00          20.00
C            2           1.00            2.00

I would like to use a macro to auto fill up the "Qty" and "Cost" field
with 0 (zero) if they are blank or empty.

May I know how to achieve it?

Thank you.
Ken Johnson - 10 Oct 2006 11:34 GMT
> Hi everyone,
>
[quoted text clipped - 12 lines]
>
> Thank you.

Hi altric,

try this macro on a copy of your data...

Public Sub Blank_to_zero()
Dim rngCell As Range
Dim rngRange As Range
On Error GoTo CANCELLED
Set rngRange = Application.InputBox( _
Title:="Blanks to Zeros", _
Prompt:="Select cells for changing blanks to zeros.", _
Default:=Selection.Address, _
Type:=8)
For Each rngCell In rngRange
With rngCell
If .Value = "" Then Let .Value = 0
End With
Next rngCell
CANCELLED:
End Sub

Ken Johnson
Roger Govier - 10 Oct 2006 11:42 GMT
Hi

For a non-macro solution.
Enter 0 in a spare cell on your sheet, mark the cell >Copy
Mark the complete range of values in B2:C4>Paste Special>Add

Signature

Regards

Roger Govier

> Hi everyone,
>
[quoted text clipped - 12 lines]
>
> Thank you.
Dave Peterson - 10 Oct 2006 14:00 GMT
Another non-macro solution:

Select the range to fix (include the filled in cells)
edit|goto|special
check Blanks
type 0
but hit ctrl-enter (instead of enter) to fill all the empty cells with 0's.

It could look like this in code:

   Dim myRng As Range
   Set myRng = Selection  

   On Error Resume Next
   myRng.Cells.SpecialCells(xlCellTypeBlanks).Value = 0
   On Error GoTo 0

> Hi everyone,
>
[quoted text clipped - 12 lines]
>
> Thank you.

Signature

Dave Peterson

Lori - 10 Oct 2006 15:56 GMT
Another solution: Choose Edit -> Replace with nothing in the Find box
and Replace box set to 0

> Hi everyone,
>
[quoted text clipped - 12 lines]
>
> Thank you.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.