1

I tried to post my code here but keeps getting errors and not sure how to resolve.

I've got an Excel VBA code that compares 2 sheets for changes referring to Sheet1 and Sheet2 and all works great. The problem I am having now is that I've was asked to allow the user, through a series of questions, to customize the sheet name. That customization will always either be the word comments with todays date and time i.e. Comments 03-04-2021 15.31.55, or updated with todays date and time i.e. updated 03-04-2021 15.31.59

The name can be forever changing but will always have either comments or updated in the text portion, nothing else. How can I refer to those sheets replacing the Sheet2 and Sheet1 portion of my macro?

ZygD
  • 22,092
  • 39
  • 79
  • 102
Paula
  • 11
  • 1

1 Answers1

1

Assuming you always have 2 sheets and you want to reference data or properties of the sheets, then you may be able to reference the sheet by number.

For example, to get the name of the first sheet use something like -

Sheets(1).Name

Another example, to get the value of cell A1 in the first sheet use something like -

Sheets(1).Cells(1, 1).Value
Dave
  • 61
  • 5