Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default How do I Shorten Object References?

ThisWorkbook.Sheets("Vessel")
I'm always referring to this Sheet and Sheet "Operations"
I've seen code where people shorten the objects...
How exactly do I do that?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default How do I Shorten Object References?

Dim ws as worksheet
set ws = ThisWorkbook.Sheets("Vessel")

ws.Range("A1").value = "Shorten"
"Benjamin" wrote:

ThisWorkbook.Sheets("Vessel")
I'm always referring to this Sheet and Sheet "Operations"
I've seen code where people shorten the objects...
How exactly do I do that?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How do I Shorten Object References?

Benjamin,

Here's a way, you only need to SET the shhet once and thereafter you can
refer to as in my example

Dim MySheet As Object
Set MySheet = ThisWorkbook.Sheets("Vessel")


MySheet.Range("A1").Value = 999

Mike

"Benjamin" wrote:

ThisWorkbook.Sheets("Vessel")
I'm always referring to this Sheet and Sheet "Operations"
I've seen code where people shorten the objects...
How exactly do I do that?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default How do I Shorten Object References?

Per Mike H:
Here's a way, you only need to SET the shhet once and thereafter you can
refer to as in my example

Dim MySheet As Object
Set MySheet = ThisWorkbook.Sheets("Vessel")


MySheet.Range("A1").Value = 999


Also, that seems tb (theoretically, at least) faster - since the
code doesn't have to go through the list of worksheets with every
ref.
--
PeteCresswell
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default How do I Shorten Object References?

And if you're working with the object a lot, you can shorten things even
further using the With statement:

With MySheet
.Range("A1").Value = 3
.Name = "MySheetName"
End With

HTH,

Eric

"Mike H" wrote:

Benjamin,

Here's a way, you only need to SET the shhet once and thereafter you can
refer to as in my example

Dim MySheet As Object
Set MySheet = ThisWorkbook.Sheets("Vessel")


MySheet.Range("A1").Value = 999

Mike

"Benjamin" wrote:

ThisWorkbook.Sheets("Vessel")
I'm always referring to this Sheet and Sheet "Operations"
I've seen code where people shorten the objects...
How exactly do I do that?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default How do I Shorten Object References?

Benjamin,

You can also use the codename of the sheet without assigning it to a variable: change the codename
to something meaningful by selecting the sheet and changing the name in the properties window. For
example, use v as the name of sheet "Vessel"

Then v is an object that you can reference - type v and a period, and the autosense properties for a
worksheet will show up.

HTH,
Bernie
MS Excel MVP


"Benjamin" wrote in message
...
ThisWorkbook.Sheets("Vessel")
I'm always referring to this Sheet and Sheet "Operations"
I've seen code where people shorten the objects...
How exactly do I do that?



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default How do I Shorten Object References?

Thanks for all the posts everyone!
Make my coding life a LOT easier!

"Bernie Deitrick" wrote:

Benjamin,

You can also use the codename of the sheet without assigning it to a variable: change the codename
to something meaningful by selecting the sheet and changing the name in the properties window. For
example, use v as the name of sheet "Vessel"

Then v is an object that you can reference - type v and a period, and the autosense properties for a
worksheet will show up.

HTH,
Bernie
MS Excel MVP


"Benjamin" wrote in message
...
ThisWorkbook.Sheets("Vessel")
I'm always referring to this Sheet and Sheet "Operations"
I've seen code where people shorten the objects...
How exactly do I do that?



.

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
How to Shorten a repetitive formula to include more references. Romileyrunner1 Excel Worksheet Functions 7 August 31st 09 10:32 PM
Object Library invalid or contains references to object defintions John Excel Programming 1 July 24th 09 11:00 AM
Object references Don[_31_] Excel Programming 2 December 1st 08 01:30 AM
Comparing Object References INTP56 Excel Programming 5 August 28th 08 04:17 PM
Object Library References Nelson[_6_] Excel Programming 1 December 10th 03 03:31 AM


All times are GMT +1. The time now is 12:46 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"