+ Reply to Thread
Results 1 to 6 of 6

Macro to autofill a number in empty cells in a column

  1. #1
    Registered User
    Join Date
    01-23-2009
    Location
    Chicago
    MS-Off Ver
    Excel 2003
    Posts
    58

    Macro to autofill a number in empty cells in a column

    Hi,
    I have two issues:
    1. I need a macro to find a unique number, say a 10 digit number starting with 4100.. and move it 1 row down and 3 rows to the left. It needs to look only in one column (E) for this number. This row contains several unique numbers, variable number of blank cells between them, all having 10 digits and starting with 4100.. - So the macro needs to repeat this for every unique number.

    2)Once it does this, I need it to autofill the unique number in all the cells in column A until the next unique number is reached.

    Can anyone help me with this please?

    Thanks.
    Last edited by excelaspire0219; 02-10-2009 at 10:55 AM.

  2. #2
    Registered User
    Join Date
    01-22-2009
    Location
    Brno, Czech Republic
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Macro to autofill a number in empty cells in a column

    Hi, it would be very helpful if you attache the example file. It shall be easy job. I havn't understood exactely.
    Do you want to search for one specific number and move it or all not empty cells in column E shall be moved?
    Petr

  3. #3
    Registered User
    Join Date
    01-23-2009
    Location
    Chicago
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: Macro to autofill a number in empty cells in a column

    Hi,
    Here is the sample, sheet 1 is how the file looks and sheet 2 is how I would it to look (the number in blue font should be deleted) as you can see the number in blue font moved one row down and one row to the left, and got autofilled. It is ok if the number autofills until it reaches the next number, that way I can write a code to delete the rows in which certain cells are blank.

    Hope this helps.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-22-2009
    Location
    Brno, Czech Republic
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: Macro to autofill a number in empty cells in a column

    Hi, try this and let me know if it functions. Regards. Petr

    Sub autofill()
    Dim Cell As Range
    Dim Num As String

    Set Cell = Range("B1")
    Do Until Cell = "END OF REPORT"
    Select Case Left(Cell.Value, 3)
    Case "420"
    Num = Cell.Value
    Cell.Value = ""
    Case Is <> ""
    Cell.Offset(0, -1).Value = Num
    End Select
    Set Cell = Cell.Offset(1, 0)
    Loop
    End Sub

  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

    Re: Macro to autofill a number in empty cells in a column

    PetrH,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    _________________________________________


    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 !!!

  6. #6
    Registered User
    Join Date
    01-23-2009
    Location
    Chicago
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: Macro to autofill a number in empty cells in a column

    Thanks Petr, I will try it out and let you know if it worked.

+ 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