LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Correct way to use names defined globally in a workbook, in VBA


What is the correct way to use names defined globally in a
workbook, in VBA scripts?

From Excel, I can access any name defined in any worksheet
(sheet1) from anywhere in the workbook. But this is not
seem to be the case for VBA.

For example:

- I have a range A1:A10 with name PayHr in sheet1.

- When I crate a sub Initialize() in sheet2:
Private Sub Initialize()
Set payRange = Me.Range("HrPay") 'payRange is defined
globally on the top section.
Debug.Print myRange.Cells(1, 1)
End Sub

This produced a compiler error: Method or data member not
found.
However, the code works when I define HrPay in sheet2.

I tried to add worksheets("sheet1") in the Set line, but not
sure if I used the correct syntax, all trails returned
errors so far.

Thanks,
pac



 
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
Globally available defined names? Martin Excel Worksheet Functions 1 September 12th 08 10:41 PM
Defined Names in Workbook Beaniecounter Excel Worksheet Functions 3 January 18th 08 09:30 PM
Tranferring names defined in one excel workbook to another workboo Dinesh Excel Discussion (Misc queries) 1 July 1st 06 05:34 AM
How to delete all defined names from a workbook? Dmitry Kopnichev Excel Worksheet Functions 15 November 14th 05 03:26 PM
How to delete all defined names from a workbook? Dmitry Kopnichev Links and Linking in Excel 15 November 14th 05 03:26 PM


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