开发者

Losing ActiveCell.Value when closing TextBox from which value copied

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, T开发者_JAVA技巧he 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


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


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


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜