View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Die_Another_Day Die_Another_Day is offline
external usenet poster
 
Posts: 644
Default append data from text box

Sub AddCustomer()
If Sheets("Sheet2").Range("A1") = "" Then
Sheets("Sheet2").Range("A1") = Sheets("Sheet1").tb1.Value
Else
Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0) =
Sheets("Sheet1").tb1.Value
End If
End Sub

Try that.

Die_Another_Day
Qaspec wrote:
If the text box and cell reference are on different sheets how does this
affect the sub?

"Die_Another_Day" wrote:

Sub AddCustomer
if Range("A1") = "" then
Range("A1") = tb1.Value
Else
Range("A" & Rows.Count).End(xlUp).Offset(1,0) = tb1.Value
End If
End Sub

Add the Command Button from the forms toolbar, then choose this macro
(AddCustomer) to be ran when clicked

Die_Another_Day
Qaspec wrote:
I have a text box tb1 on sheet1 that contains a customer name. I would like
tb1 to update the value of cell a1 on sheet2 with the customer name. In
addition I would like to append the data each time the customer name is
changed within the text box. So if sheet2 a1 already contains a value then
sheet2 a2 and so on. Would it be possible to put this in a function called
from a command button that would only update the information when the command
button is selected and also deleted the contents of the text box after the
update? I know this would be easily done in an access db but the employees I
am creating this for do not have licenses to use it. Thanks for any help.