VBA auto refresh cell value in userform - textbox.

secoo140

Board Regular
Joined
Oct 12, 2013
Messages
85
Office Version
  1. 2010
Platform
  1. Windows
Hello,
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:
'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()'web.tr'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:
,
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.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi,
see if linking the control to the range will do what you want

replace your Initialize event code with following

Code:
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.


Dave
 
Upvote 0
there is a problem,
in range b7
there is a formula called "=IF(B8>9;"C";IF(B8>6;"B";"A"))"

this script overwrites it.
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,139
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top