hallpett
asked on
Calculated field in userform
I have a userform with two textboxes. Textbox1 have controlsource C2, Textbox2 have controlsource C3. How can I show the sum of this two fields on the userform. I tried with another Textbox with controlsource cell C4 where I put =C2+C3. But the value from the userform overwrites the formula in C4 so this does'nt work. Appreciate an tips.
ASKER
I'm not so experienced with vba in excel. Where should I put this line to make it work?
Perhaps You should set the Locked property of TextBox3 to True, so that it can't be edited
ASKER
"Perhaps You should set the Locked property of TextBox3 to True, so that it can't be edited"
Can't find a Locked property but I have tried to set the Enabled property to false. Don't work. The value you see when you open the user form will still overwrite the formula in the controlsource cell.
Can't find a Locked property but I have tried to set the Enabled property to false. Don't work. The value you see when you open the user form will still overwrite the formula in the controlsource cell.
How does that value get there? In my tests, the value is taken from the cell when the form is initialised.
ASKER
The value is taken from the cell when the form is opened, but when you change value in textbox1 (cell C2) or textbox2 (cell C3), then textbox3 (cell C4, with formula =C2+C3) get a new value from cell C4 that textbox3 overwrites back to C4. I'm propably not the best to explain but hope this is understandable.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked just fine. Thank you!
what about
TextBox3.Value = TextBox1.Value + TextBox2.Value