Question

I'm working on a userform for an excel sheet I'm working on. I have a specific text box in the userform for a work order number (named txtWO). I would like to pre-concatenate the user-entered value from this text box (a 5-digit string) with the text 'WO-' and then insert it into a cell in the worksheet. The small bit of VBA I have written to do this is shown below.

ws.Cells(iRow, 2).Formula = "=CONCATENATE(""WO-"",me.txtWO.Value)"

Where iRow is a value, formatted as long, that represents the value of the first empty row in the worksheet.

This is all syntactically correct, as far as the VBA is concerned, but after the the value is inserted in the cell, I receive a #NAME? error. When I show the calculation steps for the formula, 'Me.txtWO.Value' evaluates to a #NAME? error.

I can't tell if this is happening because something is wrong with my VBA, or if I am misunderstanding how to work with text box values. But if anyone can shed any light, it would be much appreciated.

Thanks.

-Sean

Was it helpful?

Solution

Excel's cells can't access the textbox value. Just do everything in VBA like so:

ws.Cells(iRow, 2).Value = "WO-" & me.txtWO.Value
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top