tags:

views:

82

answers:

3

Hi Programmers, So I'm using VBA UserForm in Excel to capture values. Problem is that after assigning value to ActiveCell and after value initially appearing in cell, The value disappears when I Close TextBox. I Think I Understand why this happens, just Don't know how to preserve value after closing TextBox. Thanks in Advance. Paul L

A: 

Thanks astander Thanks for responding but i figured out how to avoid problem . A solution is to avoid having to close TextBox indefinately. Doing this by using modal parameter of Show method as shown below

UserForm1.Show (vbModeless)

Not most elegant solution maybe but it works for now. Anyway I am still at Tinkering stage of working with VBA. Trying to teach myself using book and online resources.Thanks again Paul L

Paul L
@Paul, you could still provide the code as someone might have a better solution, or someone could find your answer helpful in future.
Peter Lang
A: 

Is your textbox bound to a cell? If so, just avoiud that and drop the textbox value into the cell manually.

Bob Phillips
A: 

I found the easiest way to do this is with variables. Eg

Sub textmove()
Dim textdata

textdata = txtbox.text
Range("A1").value = textdata

End Sub

Not sure if this helps, but I have always found it easier to do this in two stages (get the data, then assign the data to a cell). Im sure there is a more correct and efficient way to do it, however this has never failed me!

Rob A