Results 1 to 4 of 4

Fill blank cells with 0 or alternative number

Threaded View

  1. #1
    Forum Contributor
    Join Date
    03-22-2006
    Location
    UK
    MS-Off Ver
    Office 2013
    Posts
    275

    Fill blank cells with 0 or alternative number

    Hi all

    I have a worksheet which is basically just for data entry; however some entries only require minimal data, leaving the cells in 3 columns blank.

    I have just come across this code in another post (courtesy of Simon Lloyd) which is ideal for general purposes.

    Sub Fill_Blanks()
    Dim MyCell As Range
    For Each MyCell In Range(Selection.Address)
    If MyCell = vbNullString Then
    MyCell.Value = 0
    End If
    Next
    End Sub
    Ideally I would like to customise this code to do the following:

    1) Restrict the range selection for use with columns D / E / F on Sheet1 for example, so that the range selection stops at the last filled cell in column C.

    2) It may be necessary to change the zero value in either D / E / F at a later date, so I would like the code to have individual values for each column, if that makes sense.

    3) This is not essential but can the code be set to run on a row by row basis for that specific worksheet. In other words, if there is no entries in D / E / F of row 25, when you move down to row 26, the zero input is automatically filled in rather than invoking a macro at the end.

    Please note my knowledge of VBA is virtually zero!

    TIA ...spellbound
    Last edited by VBA Noob; 09-14-2008 at 04:21 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Auto fill blank cells with data in a cell above
    By StudentMod in forum Excel General
    Replies: 4
    Last Post: 05-09-2008, 04:37 PM
  2. Replies: 3
    Last Post: 11-22-2007, 07:53 AM
  3. Skipping blank cells in a list to create an uninterrupted list
    By bdance in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-02-2007, 06:26 PM
  4. Locking non blank cells in range
    By chris100 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-13-2007, 08:22 PM
  5. Replies: 0
    Last Post: 09-27-2006, 02:05 PM

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