Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Tye Thompson   on Mar 02 In MS Office Category.

  
Question Answered By: Abagail Cohen   on Mar 02

You can declare s1 as a public worksheet  object as shown below. Just
place the declaration at the top of any module. Once assigned in the
sub Test1(), s1 is accessible in Test2() also. Note that "Set" is
used when assigning objects. If you are dealing with Objects and
forget to use "Set", you get an error.


'declarations
Public s1 As Worksheet

Sub Test1()
Set s1 = Worksheets("Sheet1")
End Sub

Sub Test2()
Set s2 = s1
MsgBox s2.Name
End Sub

Share: 

 
 
Didn't find what you were looking for? Find more on Accessing set s1=worksheets("input") globally Or get search suggestion and latest updates.