+ Reply to Thread
Results 1 to 3 of 3

Filling empty cells

Hybrid View

  1. #1
    Registered User
    Join Date
    02-04-2011
    Location
    Olkusz
    MS-Off Ver
    Excel 2007
    Posts
    43

    Filling empty cells

    Hello!

    I had to add a little code to another macro to make it fill empty cells with a specified number (973).

    I found almost ready code and modified it to fit my needs.

    Currently it looks like that:
    Sub puste()
    
      Dim Area As Range, LastRow As Long
      On Error Resume Next
      LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, _
                   SearchDirection:=xlPrevious, _
                   LookIn:=xlFormulas).Row
      For Each Area In ActiveCell.EntireColumn(1).Resize(LastRow). _
                   SpecialCells(xlCellTypeBlanks).Areas
        Area.Value = "973"
      Next
    End Sub
    I have 2 questions:
    1. Is there an easier way to do it? Maybe a lot faster one.
    2. What do I have to change to make it work on column A instead of current selection?

    Thanks for all the tips!
    Last edited by bukimiak; 03-17-2011 at 08:15 AM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Filling empty cells

    hi, bukimiak, this will place 973 in empty cells in the used range of column A:

    Range([a1], Cells(Rows.Count, "a").End(xlUp)).Replace What:="", Replacement:=973

  3. #3
    Registered User
    Join Date
    02-04-2011
    Location
    Olkusz
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Filling empty cells

    Wow, as simple as that.

    I think I tried with "replacement" but I gave "" instead of " " and it did not work.
    (I forgot about the space in the middle).

    Thank you for your help!

+ 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