Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 90251

Userform initialize without rewriting data in the cell

$
0
0

I have been wondering about this one for a while now.

Let's say I have a formula in A1, Worksheet("Main")

=IF(B2="English";"Good morning";"Guten Morgan")

Then I have userform with code:

Private Sub TextBox1_Change()
ThisWorkbook.Worksheets("Main").Range("A1").Value = Me.TextBox1.Text
End Sub

Private Sub UserForm_Initialize()
Me.TextBox1.Text = ThisWorkbook.Worksheets("Main").Range("A1").Value
End Sub

How can I make it work so, that if I don't input anything into textbox, it will keep displaying functions result. If I will start to type text into textbox it will input my typed text to A1. Now if I open the userform it will overwrite A1 with the text in textbox and there will be no formula anymore. So if I change language in B2 result will no longer be interfaced into textbox.

Can be also some other approach with VBA. Everything is acceptable as long as logic will work.

I have tried to use textbox properly, something like linkedsource or similar, but it is crashing excel workbook sometimes. That's why I am trying to avoid it.


Viewing all articles
Browse latest Browse all 90251


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>