NCC
NCC

Reputation: 819

How to set a mouse to a particular cell in all worksheets?

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?

Upvotes: 1

Views: 1922

Answers (1)

Siddharth Rout
Siddharth Rout

Reputation: 149297

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?

Upvotes: 3

Related Questions