Sheet.Select is not working - why?

G

Guest

Hi,
I have written code as below:
Private Sub Worksheet_Deactivate()
Dim sh, Target
On Error GoTo ErrorHandler
sh = ActiveSheet.CodeName
Application.EnableEvents = False
CompSel
Debug.Print sh
MsgBox sh & ".Select"
sh.Select
' Sheet5.Select
ErrorHandler:
Application.EnableEvents = True
End Sub

Why this code does not accept "sh.Select" but "Sheet5.Select" is OK. "MsgBox
sh & ".Select"" gives exatly same output.

Thanks
MakeLei
 
G

Guest

because you assign sh as codename not sheet object

try to change :

set sh = ActiveSheet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top