Consulting

Results 1 to 5 of 5

Thread: Solved: Copy values to Empty cells below filled cells in selection

  1. #1

    Solved: Copy values to Empty cells below filled cells in selection

    Dears,

    I'd like to write Macro to Copy values to Empty cells below filled cells in selection
    For example: if pic.1 is the input data, I'd like Macro to give me output as in pic.2

  2. #2
    VBAX Regular
    Joined
    Nov 2010
    Location
    Las Vegas Nv
    Posts
    74
    Location
    [vba]
    Public Sub blah()
    thecurrent = ""
    For x = 2 To ActiveSheet.UsedRange.Rows.Count
    If ActiveSheet.Range("a" & x).Formula <> "" Then
    thecurrent = ActiveSheet.Range("a" & x).Formula
    Else
    ActiveSheet.Range("a" & x).Formula = thecurrent
    End If
    Next x
    End Sub
    [/vba]
    ***edit*** forgot to increment variable

    ***edit 2.0*** i'm retarded today. forgot that i'd used a for not a while... incrementing obviously not necessary

  3. #3
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    You can use plain Excel (without macros)
    1. Set Data >> Filter
    2. Set the column "Action" Filter to "Blanks" while "Name" to "NonBlanks"
    3. Then in the topmost cell considering it is A3, insert formula like
    =A2
    4. Copy the formula to the last Blank Cell. Excel will adjust the penultimate cell address on its own.
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

  4. #4
    Thanks Sean, that's exactly what I'm looking for..

  5. #5
    VBAX Regular
    Joined
    Nov 2010
    Location
    Las Vegas Nv
    Posts
    74
    Location
    no problem, glad to help

Posting Permissions

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