Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Changing tab color locks the worksheet

Below is the code where I am successfully changing the worksheet tab color
under a certain conditon. However, after the tab is changed, I cannot
navigate away from that spreadsheet to another one. It is as if it is
locked. I watched the code as it ran and it ran thru "end sub". I am using
VBA 6.5 and excel 2003. Any ideas?

Private Sub Worksheet_Deactivate()
Debug.Print "order deactivate"
Dim orderWS As Worksheet
Dim tabRg As Range
Set orderWS = ThisWorkbook.Worksheets(activesheet)
Set tabRg = orderWS.Range("F40")

' check if carrier has been assigned and then change color tab if it has

Debug.Print tabRg.Value
'If tabRg.Value " " Then
'Sheets(activesheet).Select
' ActiveWorkbook.Sheets(activesheet).Tab.ColorIndex = 35
'End If


ErrorProcess:
If Err.Number < 0 Then
MsgBox Err.Description & " In worksheet-deactivate", vbCritical, "Error
# " & Err.Number
End If


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Changing tab color locks the worksheet

So you just want to use the color of the tab as a flag--green is ok (and maybe
red for bad)?

If that's ok, then maybe...

Option Explicit
Private Sub Worksheet_Deactivate()

Dim tabRg As Range

'Me is the object owning the code--in this case, the Order Worksheet
Set tabRg = Me.Range("F40")

If Trim(tabRg.Value) = "" Then
'it's empty, leave the tab color alone???
'or change it to red (for me)?
Me.Tab.ColorIndex = 3
Else
Me.Tab.ColorIndex = 35
End If

End Sub

Phyllis wrote:

Below is the code where I am successfully changing the worksheet tab color
under a certain conditon. However, after the tab is changed, I cannot
navigate away from that spreadsheet to another one. It is as if it is
locked. I watched the code as it ran and it ran thru "end sub". I am using
VBA 6.5 and excel 2003. Any ideas?

Private Sub Worksheet_Deactivate()
Debug.Print "order deactivate"
Dim orderWS As Worksheet
Dim tabRg As Range
Set orderWS = ThisWorkbook.Worksheets(activesheet)
Set tabRg = orderWS.Range("F40")

' check if carrier has been assigned and then change color tab if it has

Debug.Print tabRg.Value
'If tabRg.Value " " Then
'Sheets(activesheet).Select
' ActiveWorkbook.Sheets(activesheet).Tab.ColorIndex = 35
'End If

ErrorProcess:
If Err.Number < 0 Then
MsgBox Err.Description & " In worksheet-deactivate", vbCritical, "Error
# " & Err.Number
End If


End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Changing tab color locks the worksheet

Hi Dave,
Thanks for your response. I am able to successfully change the tab color
with the code I provided. The problem is that after the code changes the
tab, I am not able to select another worksheet. I am locked onto the
worksheet that I changed the tab color on. Why???

"Dave Peterson" wrote:

So you just want to use the color of the tab as a flag--green is ok (and maybe
red for bad)?

If that's ok, then maybe...

Option Explicit
Private Sub Worksheet_Deactivate()

Dim tabRg As Range

'Me is the object owning the code--in this case, the Order Worksheet
Set tabRg = Me.Range("F40")

If Trim(tabRg.Value) = "" Then
'it's empty, leave the tab color alone???
'or change it to red (for me)?
Me.Tab.ColorIndex = 3
Else
Me.Tab.ColorIndex = 35
End If

End Sub

Phyllis wrote:

Below is the code where I am successfully changing the worksheet tab color
under a certain conditon. However, after the tab is changed, I cannot
navigate away from that spreadsheet to another one. It is as if it is
locked. I watched the code as it ran and it ran thru "end sub". I am using
VBA 6.5 and excel 2003. Any ideas?

Private Sub Worksheet_Deactivate()
Debug.Print "order deactivate"
Dim orderWS As Worksheet
Dim tabRg As Range
Set orderWS = ThisWorkbook.Worksheets(activesheet)
Set tabRg = orderWS.Range("F40")

' check if carrier has been assigned and then change color tab if it has

Debug.Print tabRg.Value
'If tabRg.Value " " Then
'Sheets(activesheet).Select
' ActiveWorkbook.Sheets(activesheet).Tab.ColorIndex = 35
'End If

ErrorProcess:
If Err.Number < 0 Then
MsgBox Err.Description & " In worksheet-deactivate", vbCritical, "Error
# " & Err.Number
End If


End Sub


--

Dave Peterson
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Changing tab color locks the worksheet

I don't know.

The code you posted blew up on me at this line:

Set orderWS = ThisWorkbook.Worksheets(ActiveSheet)

So I wasn't able to test it.

Phyllis wrote:

Hi Dave,
Thanks for your response. I am able to successfully change the tab color
with the code I provided. The problem is that after the code changes the
tab, I am not able to select another worksheet. I am locked onto the
worksheet that I changed the tab color on. Why???

"Dave Peterson" wrote:

So you just want to use the color of the tab as a flag--green is ok (and maybe
red for bad)?

If that's ok, then maybe...

Option Explicit
Private Sub Worksheet_Deactivate()

Dim tabRg As Range

'Me is the object owning the code--in this case, the Order Worksheet
Set tabRg = Me.Range("F40")

If Trim(tabRg.Value) = "" Then
'it's empty, leave the tab color alone???
'or change it to red (for me)?
Me.Tab.ColorIndex = 3
Else
Me.Tab.ColorIndex = 35
End If

End Sub

Phyllis wrote:

Below is the code where I am successfully changing the worksheet tab color
under a certain conditon. However, after the tab is changed, I cannot
navigate away from that spreadsheet to another one. It is as if it is
locked. I watched the code as it ran and it ran thru "end sub". I am using
VBA 6.5 and excel 2003. Any ideas?

Private Sub Worksheet_Deactivate()
Debug.Print "order deactivate"
Dim orderWS As Worksheet
Dim tabRg As Range
Set orderWS = ThisWorkbook.Worksheets(activesheet)
Set tabRg = orderWS.Range("F40")

' check if carrier has been assigned and then change color tab if it has

Debug.Print tabRg.Value
'If tabRg.Value " " Then
'Sheets(activesheet).Select
' ActiveWorkbook.Sheets(activesheet).Tab.ColorIndex = 35
'End If

ErrorProcess:
If Err.Number < 0 Then
MsgBox Err.Description & " In worksheet-deactivate", vbCritical, "Error
# " & Err.Number
End If


End Sub


--

Dave Peterson
.


--

Dave Peterson
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
Changing Cell Color based upon value on another worksheet DPelletier Excel Programming 2 November 5th 09 10:24 PM
Data copy locks cell in worksheet M. Nelson Excel Discussion (Misc queries) 3 March 6th 08 04:49 PM
Code Locks Up Worksheet Briefly Arnold[_3_] Excel Programming 0 January 5th 07 04:28 AM
Excel locks with Worksheet Change procedure Casey[_62_] Excel Programming 0 March 22nd 06 03:14 PM
Changing the Worksheet ScrollBars Color ! RAFAAJ2000[_2_] Excel Programming 1 June 7th 05 01:54 PM


All times are GMT +1. The time now is 05:13 AM.

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

About Us

"It's about Microsoft Excel"