Results 1 to 2 of 2

Thread: VBA auto refresh cell value in userform - textbox.
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Oct 2013
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)

    Default VBA auto refresh cell value in userform - textbox.

    I created a form whose value could be edited via userform.
    in same userform, there is a cell that shows the result of that calculation.

    how to make it dynamic?

    HTML Code:
    'Diğer değişkenler için burayı planladımPrivate Sub tbBINR_Change()    Select Case tbBINR        Case "<1,7"            X = 1        Case "1,7 - 2,2"            X = 2        Case ">2,2"            X = 3    End Select    Sheets("Kimlik").Range("D7") = XEnd SubPrivate Sub tbBAlb_Change()''nin eklediği değiştirme kodu    Select Case tbBAlb        Case ">3,5 g/dl"            X = 1        Case "2,8 - 3,5 g/dl"            X = 2        Case "<2,8 g/dl"            X = 3    End Select    Sheets("Kimlik").Range("F7") = XEnd SubPrivate Sub tbBAssit_Change()    Select Case tbBassit        Case "YOK"            X = 1        Case "Hafifçe VAR"            X = 2        Case "Belirgin ***İT VAR"            X = 3    End Select    Sheets("Kimlik").Range("H7") = XEnd SubPrivate Sub tbBHE_Change()    Select Case tbBHE        Case "YOK"            X = 1        Case "Hafifçe VAR"            X = 2        Case "Belirgin H.E VAR"            X = 3    End Select    Sheets("Kimlik").Range("F9") = XEnd SubPrivate Sub tbBBil_Change()    Select Case tbBbil        Case "<2 mg/dl"            X = 1        Case "2-3 mg/dl"            X = 2        Case ">3 mg/dl"            X = 3    End Select    Sheets("Kimlik").Range("D9") = XEnd Sub
    result of these items will be shown in tbCPS,

    HTML Code:
    Private Sub UserForm_Initialize()
    Me.tbCPS.Text = CStr(ThisWorkbook.Sheets("Kimlik").Range("B7").Value)
    end sub
    just works when I open userform for the first time.

  2. #2
    Board Regular
    Join Date
    Jul 2012
    Hampshire, UK
    Post Thanks / Like
    26 Post(s)
    1 Thread(s)

    Default Re: VBA auto refresh cell value in userform - textbox.

    see if linking the control to the range will do what you want

    replace your Initialize event code with following

    Private Sub UserForm_Initialize()
        Me.tbCPS.ControlSource = CStr(ThisWorkbook.Sheets("Kimlik").Range("B7").Address)
    End Sub
    Note: The controlsource property works both ways. The cells value displays in the textBox, but the textBox value also writes to the cell – You should Lock the textbox if you do not want users to write data from textbox to cell.


Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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