Forum Discussion
kdliske
Mar 04, 2025Copper Contributor
Need help tweaking VBA code so I can add more columns to spreadsheet
Hi, I have a macro with code that allows me to press a button that then moves rows with a certain status to another worksheet. I need to add two more columns to the worksheets, but when I do the macr...
- Mar 05, 2025
The code looks for the value "Completed" in column I.
If you insert one or more columns to the left of column I, the status will end up in another column, so you'll have to adjust the code. For example, if status is now in column K, change the line
Set xRg = Worksheets("Tasks").Range("I3:I" & I)
to
Set xRg = Worksheets("Tasks").Range("K3:K" & I)
If that is not correct, please provide more detailed information.
HansVogelaar
Mar 05, 2025MVP
The code looks for the value "Completed" in column I.
If you insert one or more columns to the left of column I, the status will end up in another column, so you'll have to adjust the code. For example, if status is now in column K, change the line
Set xRg = Worksheets("Tasks").Range("I3:I" & I)
to
Set xRg = Worksheets("Tasks").Range("K3:K" & I)
If that is not correct, please provide more detailed information.
kdliske
Mar 05, 2025Copper Contributor
Thank-you, that worked perfectly. Now I'm running into another issue. I am trying to re-use an old spreadsheet for a new purpose and the code is remembering the old table range (ex. so rather than re-starting by moving the 'Completed' row to the first empty line (row 3), it is moving it to row 2574). How would I re-set that?