Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

naming sheet object and calling it by that

  Asked By: Frankie    Date: Jan 19    Category: MS Office    Views: 623
  

Is it possible to give name to sheet object and calling it by that
whenever we need. It will be helpful if I need to change content of the
sheet at multiple locations.

Ex: One can change cells(1,2) of sheet1 named "input" by
sheet1.cells(1,2)=21.
Can the same thing be accomplished by typing
s1=worksheets(sheet1) or worksheets("input") or sheet1
s1.cells(1,2)=21

Is there any other way to do it?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Faeezah Khan     Answered On: Jan 19


Your s1= ... is almost right. Just put a Set at the front of the statement.
E.g.

Set s1=worksheets("input")

 
Answer #2    Answered By: Kanya Jainukul     Answered On: Jan 19

Yes, I was able to declare it within a subroutine but it restricts s1
to remain a local variable rather than a global variable. When I
tried putting it in declarations on top of all the subroutines, VBA
denied. Is it possible to declare Set s1=worksheets("input") as
global.

 
Didn't find what you were looking for? Find more on naming sheet object and calling it by that Or get search suggestion and latest updates.




Tagged: