7

I have a spreadsheet where I've found some code that jumps to the first empty row:

 lastRowA = Range("A" & Rows.Count).End(xlUp).Row + 1
 ActiveWorkbook.Worksheets("RO input sheet").Range("A" & lastRowA).Select

My problem is that the conditions surrounding the spreadsheet have changed so now I need to tweak the code so it jumps to the first row where cell A contains a specific text, for instance "Test123".

How can I do this in VBA?

1
  • 1
    .Find.Select. is the wrong way to do it. It is prone to errors. What if the search string is not found? Sep 17, 2013 at 12:57

1 Answer 1

10

Replace the entire code with simply:

ActiveWorkbook.Worksheets("RO input sheet").Columns(1).Find("Test123").Select
3
  • 3
    A colleague asked me how to find a row with given criteria and update a subsequent column on that row, so I took this and edited it to .find("thing").offset(0, n).formula = "=blah". They were bowled over by the resulting technological marvel. Thanks! Feb 1, 2016 at 13:06
  • Why do you have .Columns(1) in here?
    – TylerH
    Feb 8, 2017 at 18:23
  • Find needs to be used on a Range to search in, in this case all of column 1 (A). But it can be changed to any range.
    – mattboy
    Feb 9, 2017 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.