+ Reply to Thread
Results 1 to 5 of 5

Macro Fill Empty Cells

  1. #1
    Registered User
    Join Date
    02-08-2017
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    0

    Exclamation Macro Fill Empty Cells

    Hi,

    I have created the below Macro to fill empty blank cells;

    Sub TEST()
    Dim c As Range
    For Each c In ActiveSheet.Range("D3:D20000")
    If c = vbNullString Then c = "VNA"
    Next
    End Sub

    However the issue I am having its continuing right down the excel sheet, I need it to stop on the last line that contains text because its affecting the pivot table results.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166
    Hello BillyBoy86UK,

    Welcome to Excelforum. Be a part of large Excel community. Enjoy Learning.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Macro Fill Empty Cells

    Hi
    your macro is continuing to cell D2000 because that is the range you have told it to fill.
    To fill only blank cells to the last used row in the active sheet, try this :

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-08-2017
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    0

    Re: Macro Fill Empty Cells

    Much better thanks, however it stilled filled past where my text ends, not the whole sheet now but down to cell 1000, is there a bit of data to put in to stop it after the last line of text.

  5. #5
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Macro Fill Empty Cells

    Hi
    The macro should only work to the row of the last used row on the worksheet (not necessarily in column D). You might want to check if there is any content below your main table in the sheet.

    Or, if you only want to go to the last row in column D, try this:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. copy current cells and fill the empty cells below it consecutively
    By jitterbug888 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-09-2016, 10:34 PM
  2. Macro to use a vlookup to fill only cells that are empty in a column
    By cjtiger in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-24-2015, 08:19 AM
  3. Macro to fill empty cells
    By wonderd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-27-2014, 02:25 AM
  4. Auto fill empty cells macro
    By Dibbley247 in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 02-10-2013, 07:30 AM
  5. [SOLVED] Fill Empty Cells
    By srikanthk in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-30-2012, 08:13 AM
  6. macro to fill in empty cells with certain formulas or values in.
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2011, 01:43 AM
  7. Macro to fill empty cells below
    By applegatecz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2010, 01:50 PM

Tags for this Thread

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