How to change a Label.Caption with Worksheet_Activate

AjaxOpenB

New Member
Joined
Mar 5, 2009
Messages
2
I'm having difficulty getting my Worksheet_Activate to change my Label.Caption when the worksheet is activated and need some help.

I'm using two worksheets.
One with DATA in Cells and Command Button.
The second sheet is a form that takes the data
and put it into Labels, then prints out the form.
After the print, I return to the First page get the
next record and return to the form and print it out.

If I manually start with sheet 1, then manually
select sheet 2, the Label.Captions are updated.
If I do this from a Command Button they do not

Code:
'----Sheet one------------------------------------------
Private Sub CommandGameSheetPreview_Click()
Dim StartRow As Integer
Dim EndRow As Integer
Dim Msg As String
Dim i As Integer
 
StartRow = Range("E35")
EndRow = Range("E36")
 
If StartRow > EndRow Then
Msg = "ERROR" & vbCrLf & "The First Game Sheet be less than the Last Game Sheet!"
MsgBox Msg, vbCritical, APPNAME
End If
Call PageLayout
ActiveSheet.Unprotect "ora"
Sheet = ActiveSheet.Name
Game_Number = "='" & ActiveSheet.Name & "'!R34C7"
Game_Date = "='" & ActiveSheet.Name & "'!R35C7"
Game_Time = "='" & ActiveSheet.Name & "'!R36C7"
Home_Team = "='" & ActiveSheet.Name & "'!R34C9"
Away_Team = "='" & ActiveSheet.Name & "'!R35C9"
Division = "='" & ActiveSheet.Name & "'!R35C11"
Arena = "='" & ActiveSheet.Name & "'!R36C11"
ActiveWorkbook.Names.Add Name:="Game_Number", RefersToR1C1:=Game_Number
ActiveWorkbook.Names.Add Name:="Game_Date", RefersToR1C1:=Game_Date
ActiveWorkbook.Names.Add Name:="Game_Time", RefersToR1C1:=Game_Time
ActiveWorkbook.Names.Add Name:="Home_Team", RefersToR1C1:=Home_Team
ActiveWorkbook.Names.Add Name:="Away_Team", RefersToR1C1:=Away_Team
ActiveWorkbook.Names.Add Name:="Division", RefersToR1C1:=Division
ActiveWorkbook.Names.Add Name:="Arena", RefersToR1C1:=Arena
For i = StartRow To EndRow
 
Range("E34") = i
Sheets("Game Sheet").Select
Sheets("3 games - 4 teams").Select
Next i
ActiveSheet.Protect "ora"
End Sub
 
'----Sheet two------------------------------------------
Private Sub Worksheet_Activate()
MsgBox "Beginning of Activate"
Label_Game_Number.Caption = Range("A1").Text
Label_Division.Caption = Range("C1").Text
Label_Title.Caption = Range("E1").Text
Label_Game_Time.Caption = Range("U1").Text
Label_Game_Date.Caption = Range("S1").Text
Label_Arena.Caption = Range("L1").Text
Label_Home_Team.Caption = Range("R1").Text
Label_Away_Team.Caption = Range("O1").Text
MsgBox "End of Activate"
End Sub

-------------------------------------------------
As I said, the Worksheet_Activate() works
both manually (when I select the sheet tab)
and from the Command Button, but all the
Label.Caption do not....

I know this because the MsgBox's work fine.

Any Idea's whould be a great help
 
Last edited by a moderator:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
try like
sheets("sheet2").OLEObjects("label4").object.caption = "some text"
change sheet and label name to suit
 
Upvote 0
The code work if I select the worksheet tab but not if I use a Command_Button.

It's as if the Work_Sheet is working too fast for the Label.Caption to kick in.

In fact If I put a msgbox between each Label.Caption command.
The eash come up, but the caption does not work.????

Any thoughts?
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,731
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top