Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Nov 2001
    Location
    Amsterdam
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    From a string to a control (Excel 97 on NT)

    Hello

    I have a string which is the same as the name of a form control. Based on the value of this string, I want to set the value of the control, like

    Sub checkBoxes(strCode As String)
    strCode.Value = 1
    End Sub

    Obviously this doesn't work. In vbscript v5+ there is an eval function so I would be able to do something like:
    eval(strCode & ".value=1")

    I don't see such a function in VBA for Excel 97. Is there one, or failing that is there a neat way around this problem?

    Thanks in advance

    Mark

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: From a string to a control (Excel 97 on NT)

    Mark, look at help on the controls collection. You want something like
    controls(strCode).Value = vbChecked
    Only have 97 at home, so if this dosn't help, post back and I'll check tonight. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    New Lounger
    Join Date
    Nov 2001
    Location
    Amsterdam
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: From a string to a control (Excel 97 on NT)

    Perfect, thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •