+ Reply to Thread
Results 1 to 3 of 3

Formatig cells

Hybrid View

  1. #1
    Khalil Handal
    Guest

    Formatig cells

    Hi,
    I created 50 similar TextBoxes containing numbers 1 to 50 with certain
    color.
    I wan to assign macrs to each TexBox so that:
    1- copy the number inside the textbox to another cell (say D100)
    2- set that cell (D100) active.
    3- change the background color of the textbox to another color (say
    yellow). This is to know which TextBox was selected & which was not
    selected.

    Any ideas.

    Khalil




  2. #2
    liuhao
    Guest

    Re: Formatig cells

    Hi,Khalil

    Pls try follow VBA script in your xls file

    '***********************************************
    'the Vba script

    Sub Chg_Color() 'change textbox's backcolor
    i = 0
    Do
    i = i + 1
    Loop Until i = 50 Or Controls("textbox" & CStr(i)).BackColor = RGB(255,
    255, 0)
    Controls("textbox" & CStr(i)).BackColor = -2147483643
    End Sub

    Private Sub TextBox1_Change()
    Chg_Color
    TextBox1.BackColor = RGB(255, 255, 0)
    sheet1.cells(100,4) = textbox1 'suppose the range(D100) is in sheet1
    End Sub

    Private Sub TextBox2_Change()
    Chg_Color
    TextBox2.BackColor = RGB(255, 255, 0)
    sheet1.cells(100,4) = textbox2
    End Sub

    '....
    'every textbox's vba script is same ,but it need change the "number" in its
    name

    Private Sub TextBox50_Change()
    Chg_Color
    TextBox50.BackColor = RGB(255, 255, 0)
    sheet1.cells(100,4) = textbox50
    End Sub

    '**************************************************************

    "Khalil Handal" <seminary@lpj.org> дÈëÓʼþ
    news:Oi0h6hPNFHA.2464@TK2MSFTNGP10.phx.gbl...
    > Hi,
    > I created 50 similar TextBoxes containing numbers 1 to 50 with certain
    > color.
    > I wan to assign macrs to each TexBox so that:
    > 1- copy the number inside the textbox to another cell (say D100)
    > 2- set that cell (D100) active.
    > 3- change the background color of the textbox to another color (say
    > yellow). This is to know which TextBox was selected & which was not
    > selected.
    >
    > Any ideas.
    >
    > Khalil
    >
    >
    >




  3. #3
    Khalil Handal
    Guest

    Re: Formatig cells

    Hi,
    I tried but had the compilation error:

    Comppile error:
    Sub or Function not defined

    in the line:
    Loop until i=50 Or Controls.....

    (the blue color on the word "Controls"


    What I want is that when I click on the TextBox the change will take place.
    (HopeI was clear from the begining)

    Khalil




+ Reply to Thread

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