+ Reply to Thread
Results 1 to 9 of 9

Writing '0' to a particular range of cells

  1. #1
    Registered User
    Join Date
    07-24-2007
    Location
    Oregon
    Posts
    79

    Writing '0' to a particular range of cells

    Hi,

    I have a range of cells named , for example as "test_data". How can I achieve the following:
    If the cell is blank then write '0'
    else do nothing if the cell has some characters.

    Thanks

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Maybe

    =IF(A1="",0,"Do something else here")
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Select the range

    Do Edit > Goto > Special > Blanks

    Type 0, Ctrl+Enter

  4. #4
    Registered User
    Join Date
    07-24-2007
    Location
    Oregon
    Posts
    79
    Quote Originally Posted by shg
    Select the range

    Do Edit > Goto > Special > Blanks

    Type 0, Ctrl+Enter
    Great!!! Thanks it worked like a charm....You are awesome. Now the only thing that remains is to somehow write a formula or a VBA code for this.

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Please Login or Register  to view this content.
    VBA Noob

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Please Login or Register  to view this content.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello modest_16081982,

    Just an addendum to Shg's andVBA Noob's last post. When using the SpecialCells method, it will generate an error if no blank cells are found in the given range. If you don't trap the error, your macro will be interrupted. Here's an example of trapping the error if it occurs, and then restoring normal error handling.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  8. #8
    Registered User
    Join Date
    07-24-2007
    Location
    Oregon
    Posts
    79
    Quote Originally Posted by Leith Ross
    Hello modest_16081982,

    Just an addendum to Shg's andVBA Noob's last post. When using the SpecialCells method, it will generate an error if no blank cells are found in the given range. If you don't trap the error, your macro will be interrupted. Here's an example of trapping the error if it occurs, and then restoring normal error handling.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Great!!! Thank all of you three guys for helping me out.

    You guys rock.

  9. #9
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Thanks Leith as usual,

    modest_16081982,

    Good to see you got a solution


    VBA Noob

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1