Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default properties of object on another sheet

Hey everyone! I'm stuck on this. I need to set a string
variable in the VBA for Sheet1 with the value stored in
the Text property of a TextBox on Sheet2. Is there a way
to reference an object from another sheet within the same
workbook?

Something like this:

Dim strServerName, strDatabaseName As String

strServerName = ??Sheets("Sheet2").??.txtServerName.Text

strDatabaseName = ?????????.txtDatabaseName.Text

Please advise.
DBAL

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default properties of object on another sheet

Hi DBAL

Private Sub CommandButton1_Click()
MsgBox Sheet2.TextBox1.Text
MsgBox Sheets(2).TextBox1.Text
MsgBox Sheets("Sheet2").TextBox1.Text
End Sub

Pick the line that suits your needs. Sheet2 is the sheet's code name. It
will stick to the worksheet no matter where you place it or what you rename
it to. Sheets(2) is the second sheet in the workbook at the moment.
Sheets("Sheet2") is the one named Sheet2, no matter where it's located.

HTH. Best wishes Harald

"DBAL" skrev i melding
...
Hey everyone! I'm stuck on this. I need to set a string
variable in the VBA for Sheet1 with the value stored in
the Text property of a TextBox on Sheet2. Is there a way
to reference an object from another sheet within the same
workbook?

Something like this:

Dim strServerName, strDatabaseName As String

strServerName = ??Sheets("Sheet2").??.txtServerName.Text

strDatabaseName = ?????????.txtDatabaseName.Text

Please advise.
DBAL



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default properties of object on another sheet

Thanks Harald. I will try implementing one of your
suggestions. I especially like the first one because if
the sheet is renamed or moved the code will still work!
Thanks a million. DBAL.


-----Original Message-----
Hi DBAL

Private Sub CommandButton1_Click()
MsgBox Sheet2.TextBox1.Text
MsgBox Sheets(2).TextBox1.Text
MsgBox Sheets("Sheet2").TextBox1.Text
End Sub

Pick the line that suits your needs. Sheet2 is the

sheet's code name. It
will stick to the worksheet no matter where you place it

or what you rename
it to. Sheets(2) is the second sheet in the workbook at

the moment.
Sheets("Sheet2") is the one named Sheet2, no matter

where it's located.

HTH. Best wishes Harald

"DBAL" skrev i melding
...
Hey everyone! I'm stuck on this. I need to set a

string
variable in the VBA for Sheet1 with the value stored in
the Text property of a TextBox on Sheet2. Is there a

way
to reference an object from another sheet within the

same
workbook?

Something like this:

Dim strServerName, strDatabaseName As String

strServerName = ??Sheets

("Sheet2").??.txtServerName.Text

strDatabaseName = ?????????.txtDatabaseName.Text

Please advise.
DBAL



.

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
Excel: how set default for Format Object Properties to Move and s thejman Setting up and Configuration of Excel 0 September 19th 05 04:29 PM
Properties of QueryTable Object Shilps Excel Programming 0 April 1st 04 11:31 AM
Word Art Object properties in VBA Arnie[_5_] Excel Programming 0 March 7th 04 03:55 AM
OLE Object -TexBox Properties SSR[_2_] Excel Programming 2 December 31st 03 08:22 AM
iterating through all properties of an object Barney Fife Excel Programming 4 August 22nd 03 03:18 AM


All times are GMT +1. The time now is 11:16 AM.

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

About Us

"It's about Microsoft Excel"