Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
ctrl select not working in 07 | Excel Discussion (Misc queries) | |||
Range().Select not working | Excel Programming | |||
ActiveSheet.Next.Select not working! | Excel Programming | |||
Range().Select Not Working | Excel Programming | |||
Select Case in VBA not working | Excel Programming |