Dynamically Shifting rows within a spreadsheet using VB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mikechance812
    New Member
    • Mar 2007
    • 2

    #1

    Dynamically Shifting rows within a spreadsheet using VB

    Good afternoon all,

    I'm new to vb and I'm having a problem with a user request. I have created a macro that builds a spreadsheet that I need to manipulate a little bit. For every record in the worksheet that has revenue (column f) = zero, I need to move that record (row) to the bottom. I want to do this for every record that meets that criteria.

    I have the following code (which I believe works) to select and cut the data I need; it's the moving and shifting of the data that I'm stuck on:

    ' Select records with ZERO revenue and move them to the end
    raddr = "a2:j"
    Range("f:f").Se lect
    Selection.AutoF ilter Field:=1, Criteria1:="0.0 0"
    Selection.Speci alCells(xlCellT ypeLastCell).Se lect
    xrow = ActiveCell.Row
    raddr = raddr + xrow
    Range(raddr).Se lect
    Selection.Cut
    Selection.AutoF ilter

    What is the easiest way to accomplish this? Thanks VERY MUCH for your help!

    mikechance812
  • mikechance812
    New Member
    • Mar 2007
    • 2

    #2
    Can an expert in using Visual Basic with EXCEL please respond to my programming question? I really need some assistance.

    Thank you!


    Originally posted by mikechance812
    Good afternoon all,

    I'm new to vb and I'm having a problem with a user request. I have created a macro that builds a spreadsheet that I need to manipulate a little bit. For every record in the worksheet that has revenue (column f) = zero, I need to move that record (row) to the bottom. I want to do this for every record that meets that criteria.

    I have the following code (which I believe works) to select and cut the data I need; it's the moving and shifting of the data that I'm stuck on:

    ' Select records with ZERO revenue and move them to the end
    raddr = "a2:j"
    Range("f:f").Se lect
    Selection.AutoF ilter Field:=1, Criteria1:="0.0 0"
    Selection.Speci alCells(xlCellT ypeLastCell).Se lect
    xrow = ActiveCell.Row
    raddr = raddr + xrow
    Range(raddr).Se lect
    Selection.Cut
    Selection.AutoF ilter

    What is the easiest way to accomplish this? Thanks VERY MUCH for your help!

    mikechance812

    Comment

    Working...