Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In VBA check which excel sheet is active (currently shown)

Tags:

excel

vba

I'm looking for a method of checking if an excel sheet is currently active (currently shown). I'm interested in a synchronous method and not in an event.

like image 783
omer bach Avatar asked Mar 02 '11 22:03

omer bach


1 Answers

You could use set sh = ActiveSheet, or strShName = ActiveSheet.Name.
To test if sheet Xyz is active: If ActiveSheet.Name = "xyz" Then
You can also use If ActiveSheet.CodeName = "Sheet1" Then (VBE name)

like image 139
iDevlop Avatar answered Oct 10 '22 16:10

iDevlop