Johnson Jason
Johnson Jason

Reputation: 721

Last used column only up to a specific last column

I have something that works but I don't want it to look passed column 25. I don't care about anything passed column 25. I would like a version that only looks in Column 1 through 25 instead of the whole sheet.

 LastCol = wb.Sheets("INPUT SHEET").Cells(curr_row, wb.Sheets("INPUT SHEET").Columns.Count).End(xlToLeft).Column

Upvotes: 0

Views: 51

Answers (1)

Snachmo
Snachmo

Reputation: 188

(Edited with better understanding of the question)

Your code should work fine, you just need to execute .End(xlToLeft) on the 26th column of the row, instead of the last. Try:

LastCol = wb.Sheets("INPUT SHEET").Cells(curr_row, 26).End(xlToLeft).Column

Upvotes: 3

Related Questions