Results 1 to 5 of 5

VBA TextBox determines CommandButton??

Threaded View

newty VBA TextBox determines... 04-17-2010, 10:39 AM
tony h Re: VBA TextBox determines... 04-17-2010, 12:43 PM
newty Re: VBA TextBox determines... 04-17-2010, 03:17 PM
newty Re: VBA TextBox determines... 04-17-2010, 03:28 PM
shg Re: VBA TextBox determines... 04-17-2010, 03:41 PM
  1. #1
    Registered User
    Join Date
    04-17-2010
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2003
    Posts
    13

    VBA TextBox determines CommandButton??

    Hi

    I would like the numeric value of a textbox to be used to determine which one of 50 commandbuttons change its background colour. So is it possible to use the number within a commandbutton name i.e. the 4 in CommandButton4

    Many thanks for any soloutions, corrections, ideas or other options

    'something along the lines of 
    
    Sub search () `search button
    CommandButton(TextBox1.value).BackColor = vbGreen
    End sub
    
    'to replace listing each option in this way 
    
    <Sub search () `search button> 
    
    If TextBox1 = 1 Then
    CommandButton1.BackColor = vbGreen
    End If
    
    If TextBox1 = 2 then
    CommandButton2.BackColor = vbGreen
    End If
    `etc etc
    End Sub
    
    'Also is there and easy way to select multiple buttons to change them back to red when a reset commandbutton is pressed,without having to list all 50.
    
    'Something like 
    
    Sub resetred () `reset button
    CommandButton(1-50).BackColor = vbRed
    End Sub
    Last edited by newty; 04-30-2010 at 09:30 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1