![]() |
Sheet.Select is not working - why?
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 |
Sheet.Select is not working - why?
because you assign sh as codename not sheet object
try to change : set sh = ActiveSheet -- Regards, Halim "Makelei" wrote: 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 |
Sheet.Select is not working - why?
Thanks Halim,
That solved my problem. BR MakeLei "Halim" wrote: because you assign sh as codename not sheet object try to change : set sh = ActiveSheet -- Regards, Halim "Makelei" wrote: 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 |
All times are GMT +1. The time now is 10:38 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com