Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default using variable for a control name

can a variable be used as a control name?

Dim i As Integer
Dim cnDayLabel As Control 'or should this be as a String?

For i = 1 To 7
cnDayLabel = "DayLabel" & i
cnDayLabel.Visible = False
Next i


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default using variable for a control name

Hi Mark,

If they are control toolbox con trols, use

Dim cnDayLabel As OLEObject 'or should this be as a String?

For i = 1 To 7
Set cnDayLabel = ActiveSheet.OLEObjects("DayLabel" & i)
cnDayLabel.Visible = False
Next i

If they forms controls, use

Dim i As Integer
Dim cnDayLabel As Shape

For i = 1 To 7
Set cnDayLabel = ActiveSheet.Shapes("DayLabel" & i)
cnDayLabel.Visible = False
Next i

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"mark kubicki" wrote in message
...
can a variable be used as a control name?

Dim i As Integer
Dim cnDayLabel As Control 'or should this be as a String?

For i = 1 To 7
cnDayLabel = "DayLabel" & i
cnDayLabel.Visible = False
Next i




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
Passing variable values to userform control KJ-clueless Excel Discussion (Misc queries) 2 November 27th 07 10:51 PM
VLOOKUP Returns Erroneous Value When Control Data is Variable The Hawk Excel Worksheet Functions 5 April 23rd 06 04:39 AM
Variable control tip text Steve Excel Discussion (Misc queries) 3 June 30th 05 03:48 PM
Today variable to calender control anonymous Excel Discussion (Misc queries) 2 March 10th 05 03:22 PM
Variable Control Names Garry Jones Excel Programming 4 October 3rd 03 10:45 PM


All times are GMT +1. The time now is 12:04 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"