Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
WTG WTG is offline
external usenet poster
 
Posts: 11
Default Textbox.caption to cell if empty, how?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Textbox.caption to cell if empty, how?

Hi WTG,

If you run this sub after unloading your userform, passing the textbox
text to it, this should handle it --

Sub EnterInfo(str As String)
Worksheets("EmpData").Range("B1").Activate
If Not IsEmpty(ActiveCell) Then
ActiveCell.End(xlToRight).Activate
End If
If ActiveCell.Column = 256 Then
MsgBox "Last cell in row is not empty!", vbExclamation
Else
ActiveCell.Value = str
End If
End Sub

I hope that this is useful,

Gary

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Textbox.caption to cell if empty, how?

Dim rng as Range
set rng = worksheets("EmpData").Cells(rows.count,2).End(xlup )
if not isempty(rng) then
set rng = rng.offset(1,0)
end if
rng.value = Userform1.Textbox1.Text

--
Regards,
Tom Ogilvy

"WTG" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default Textbox.caption to cell if empty, how?

Try this

Sub TextToSheet()

Dim Rng As Range
Set Rng = Range("B1:B1000").Find(What:="")
Rng = Textbox1.Value

End Sub

"WTG" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Link Cell to Label Caption papaitaliano Excel Discussion (Misc queries) 1 March 21st 06 05:21 PM
Textbox.caption to cell if empty, how? WTG Excel Worksheet Functions 1 February 27th 05 09:30 AM
Textbox.caption to cell if empty, how? WTG Excel Discussion (Misc queries) 2 February 27th 05 04:03 AM
textbox.caption question CG Rosén Excel Programming 1 December 2nd 04 11:58 AM
Empty keyword in statment Application.caption? Mel Excel Programming 6 July 31st 04 11:32 PM


All times are GMT +1. The time now is 09:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"