Home » excel » excel vba – How to set a mouse to a particular cell in all worksheets?

excel vba – How to set a mouse to a particular cell in all worksheets?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I would like to set cursor/mouse pointer to cell AL2 but my program can only make this on the active worksheet

Dim a As Worksheet
For Each Sheet In ThisWorkbook.Sheets
    Range("AL2").Select
Next Sheet

Could anyone explains why the code does not do what I would like to have?

How to&Answers:

Is this what you are trying?

Dim aSheet As Worksheet
For Each aSheet In ThisWorkbook.Sheets
    aSheet.Activate
    Range("AL2").Select
Next Sheet

Having said that, one should always avoid using .Select and .Activate

Why do you want to select a cell? What exactly are you trying to do?