ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Refer to another Sheet (Easy) (https://www.excelbanter.com/excel-programming/308795-refer-another-sheet-easy.html)

No Name

Refer to another Sheet (Easy)
 
I have a pop-up text box that fires under certain
conditions in my "Sheet2". The user enters text and it is
saved to "Sheet2" when the user hits the command button.
This works fine when "Sheet2" is active, however when in
another sheet, the data is not written to Sheet2 (likely
because it is not the active sheet). How do I specify it
should be wriiten to Sheet2 in the example below?

Private Sub CommandButton1_Click()
Cells(6, 27) = UserForm1.TextBox1
Cells(6, 29) = UserForm1.TextBox2
Cells(6, 28) = Now()
Unload UserForm1
End Sub

Thanks for any tips!!

Matt.

Refer to another Sheet (Easy)
 
try:

Sheets("Sheet2").Cells(6,27).Value = UserForm1.TextBox1

cheers,
Matt.

wrote in message
...
I have a pop-up text box that fires under certain
conditions in my "Sheet2". The user enters text and it is
saved to "Sheet2" when the user hits the command button.
This works fine when "Sheet2" is active, however when in
another sheet, the data is not written to Sheet2 (likely
because it is not the active sheet). How do I specify it
should be wriiten to Sheet2 in the example below?

Private Sub CommandButton1_Click()
Cells(6, 27) = UserForm1.TextBox1
Cells(6, 29) = UserForm1.TextBox2
Cells(6, 28) = Now()
Unload UserForm1
End Sub

Thanks for any tips!!




Simon Lloyd[_550_]

Refer to another Sheet (Easy)
 
You could use the line Worksheets("Sheet2").Activate to select sheet
before the userform enters the data.

Simo

--
Message posted from http://www.ExcelForum.com


nbs

Refer to another Sheet (Easy)
 
Thanks guys...problem solved!!!
-----Original Message-----
You could use the line Worksheets("Sheet2").Activate to

select sheet 2
before the userform enters the data.

Simon


---
Message posted from http://www.ExcelForum.com/

.



All times are GMT +1. The time now is 05:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com