Forum Discussion
Need help tweaking VBA code so I can add more columns to spreadsheet
- 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.
Hi, I keep replying but then don't see my reply after, so apologies if this suddenly appears 3x.
This worked perfectly, but opened up a new problem. I am re-using an old workbook and tweaking to update for a new use. I have deleted all of the rows and cleared them, but when I click 'Completed' it is still moving them to the end of the previous table (ex. row 2557) rather than re-starting (ex. row 3). I have found bits of code and suggestions to re-set this, but none of them have worked. Any suggestions? Thank-you again.
This forum doesn't work well, I do see 3 replies now. What if you replace the lines
J = Worksheets("Completed").UsedRange.Rows.Count
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Completed").UsedRange) = 0 Then J = 0
End If
with
J = Worksheets("Completed").Range("K1000000").End(xlUp).Row
where K is the column with the status.