Textbox.caption to cell if empty, how?

W

WTG

I have a userform with a text box, that I've typed some information
into.
I now want to save that information to cell B1 on my "EmpData"
worksheet. but only if that cell is empty. if it's not, then writh the
text to cell B2.

What I thought I'd do was write an if statement that basicly says

if B(VAR)=" " Then
EmpData!B1 = TxtBox.caption
if not then Var=var+1

then just have it repeat itself over again.

and keep doing this adding a 1 to the Var until it finds a empty cell.

( B1,B2,B3,B4.....)

Can this be done?

I don't know VBA, and my VB is more then a little rusty.

Thanks for any help you can give me.

Wally
 
B

Bob Phillips

Wally,

Try this

With Worksheets("Sheet1")
cLastRow = .Cells(Rows.Count,"B").End(xlUp).Row
if cLastRow =1 And .Cells(cLastRow+1,"B").Value Then
Else
cLastRow = cLastRow + 1
End If
.Cells(cLastRow,"B").Value = TextBox1.Text
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top