Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - Worksheet_Activate Question...

The following code works when run from a Module, but not when it's run from the
Worksheet_Activate area - can you tell me why?

(the Shapes are Check Boxes from the Forms toolbar)

Private Sub Worksheet_Activate()
For i = 1 To 8
ActiveSheet.Shapes("cbx" & i).OLEFormat.Object.Text = Range("myYear")
Next
End Sub

Thanks in advance

Trevor Williams
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default XL2002 - Worksheet_Activate Question...

I didn't try going through the shapes collection.

I'd just use:

Private Sub Worksheet_Activate()
dim i as long
For i = 1 To 8
me.checkboxes("cbx" & i).caption = me.Range("myYear").value
Next i
End Sub

myYear is a single cell range on the same sheet, right?



Trevor Williams wrote:

The following code works when run from a Module, but not when it's run from the
Worksheet_Activate area - can you tell me why?

(the Shapes are Check Boxes from the Forms toolbar)

Private Sub Worksheet_Activate()
For i = 1 To 8
ActiveSheet.Shapes("cbx" & i).OLEFormat.Object.Text = Range("myYear")
Next
End Sub

Thanks in advance

Trevor Williams


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default XL2002 - Worksheet_Activate Question...

Hi Dave - thanks for the response.

The range named "myYear" is stored on a different sheet, and as I didn't ref
that sheet it returned an error. Your code is a cleaner / quicker version.
Thanks again

Trevor

"Dave Peterson" wrote:

I didn't try going through the shapes collection.

I'd just use:

Private Sub Worksheet_Activate()
dim i as long
For i = 1 To 8
me.checkboxes("cbx" & i).caption = me.Range("myYear").value
Next i
End Sub

myYear is a single cell range on the same sheet, right?



Trevor Williams wrote:

The following code works when run from a Module, but not when it's run from the
Worksheet_Activate area - can you tell me why?

(the Shapes are Check Boxes from the Forms toolbar)

Private Sub Worksheet_Activate()
For i = 1 To 8
ActiveSheet.Shapes("cbx" & i).OLEFormat.Object.Text = Range("myYear")
Next
End Sub

Thanks in advance

Trevor Williams


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default XL2002 - Worksheet_Activate Question...

Using the checkboxes from the forms toolbar, and putting the code in the
module for the sheet containing the checkboxes, it worked for me when I
switched from that sheet to another, then back. It did not work with the
checkboxes from the Control toolbox.

"Trevor Williams" wrote:

The following code works when run from a Module, but not when it's run from the
Worksheet_Activate area - can you tell me why?

(the Shapes are Check Boxes from the Forms toolbar)

Private Sub Worksheet_Activate()
For i = 1 To 8
ActiveSheet.Shapes("cbx" & i).OLEFormat.Object.Text = Range("myYear")
Next
End Sub

Thanks in advance

Trevor Williams

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
Worksheet_Activate - conditional use Neil[_5_] Excel Programming 5 July 4th 07 09:53 PM
Worksheet_Activate greg Excel Programming 2 September 26th 06 01:24 PM
Worksheet_Activate event question Barb Reinhardt Excel Programming 0 June 19th 06 06:32 PM
Worksheet_Activate Pozzo Excel Programming 5 June 7th 04 07:39 PM
Worksheet_Activate Jim Carlock[_2_] Excel Programming 2 September 25th 03 12:47 AM


All times are GMT +1. The time now is 03:03 PM.

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"