Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 182
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ctrl select not working in 07 BorisS Excel Discussion (Misc queries) 3 April 10th 07 03:51 PM
Range().Select not working clmarquez[_5_] Excel Programming 5 December 16th 05 04:45 PM
ActiveSheet.Next.Select not working! Ron McCormick[_2_] Excel Programming 2 December 15th 03 12:42 PM
Range().Select Not Working Chip Pearson Excel Programming 1 December 12th 03 02:21 PM
Select Case in VBA not working Ronald Dodge Excel Programming 3 September 11th 03 09:50 PM


All times are GMT +1. The time now is 10:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"