Vajda
Vajda

Reputation: 1794

Acquire selection on non active worksheet

I need to acquire range that is currently selected on some non-active worksheet. If I select some arbitrary range on e.g Sheet1 (A3:B5) and switch to Sheet2, selection will be changed, and if I return back to Sheet1 selection will return too (A3:B5)

I know about Selection property within Application interface, but that only returns selection of currently active sheet of currently active document.

Is there address of selected range, that will help too since I could use:

worksheet.get_Range(address);

Upvotes: 0

Views: 89

Answers (1)

Kazimierz Jawor
Kazimierz Jawor

Reputation: 19087

There is nothing like selection in sheet which is not active. I agree, when you move to any other sheet your selection will change to range which was selected when you left this sheet earlier. However, you are not able to check it if sheet is not active.

The only workaround I can think of is:

  1. switch off ScreenUpdating property of application
  2. activate the sheet you need check selection
  3. check selection
  4. return to appropriate sheet
  5. turn on ScreeUpdating

The other option would be to remember selection address each time you left sheet using string Public variable and Sheet deactivate event.

Upvotes: 2

Related Questions