Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default How to reference a named area

HI, programming in excel VBA, how can I make reference to and area I define,
example I name the area D5 to F10 and I call it Salary, how can I read the
information in the cell D5 or E8 from VBA.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default How to reference a named area

try:
MsgBox Range("Salary")(1, 1).Value
MsgBox Range("Salary")(4, 2).Value


"Orlando" wrote:

HI, programming in excel VBA, how can I make reference to and area I define,
example I name the area D5 to F10 and I call it Salary, how can I read the
information in the cell D5 or E8 from VBA.

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default How to reference a named area

Hi orlando,

I'm not sure if you are referring to a range which you have named in the
interactive mode or a range to which you have assigned to a variable in VBA.

I suggest that you copy the following code into a blank workbook and check
out what it all does.

Macro1 starts with recorded code of naming a range while working on the
worksheet. The Named range could have been created previously but I have put
it in the macro so that you have the range named properly for the following
code.

Run the macros in order by number.

Macro2 then puts some data in the cells in the named range. Note that the
named range is like a mini worksheet within a worksheet and the cells start
on row1, column 1 of the named range. When using the cells function, note
that the row number is first and the column number second. Cells(RowNumber,
ColumnNumber).
This is opposite to range("A1") where column number is first.

Comments in the other macros say what they do.

I have included code which inserts data, reads data and loops through all
the cells in the range.

Macro5: Lastly, I have included code to assign a range to a VBA variable and
then loop through the cells and write data to them.

Hope this helps and feel free to get back to me if you have any more
questions.

Regards,

OssieMac



"Orlando" wrote:

HI, programming in excel VBA, how can I make reference to and area I define,
example I name the area D5 to F10 and I call it Salary, how can I read the
information in the cell D5 or E8 from VBA.

Thanks.

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
copy contents of a named range to a section on working area Steve Excel Discussion (Misc queries) 1 May 22nd 09 10:36 PM
Using named range to extend print area for variable number of columns Pierre Excel Worksheet Functions 3 April 10th 08 05:51 PM
Excel2000:How to link Print Area with a named range Arvi Laanemets Excel Discussion (Misc queries) 5 April 8th 08 02:35 PM
Excel2000:How to link Print Area with a named range Arvi Laanemets Excel Worksheet Functions 5 April 8th 08 02:35 PM
Fill a combo box from a named area on a sheet Phil Walker Excel Programming 1 August 10th 03 05:54 PM


All times are GMT +1. The time now is 12:06 PM.

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

About Us

"It's about Microsoft Excel"