Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default RAnge as Table

Hi,
This question has probably been answered before.
I'm trying to use a range as a table, so that I can refer to columns be
their name

for example:
Set myrange = sheets("orders").Range("A10:N100")
For Each row in my range
myrange.ordertotal = myrange.subtotal + myrange.freight
Next

Wouldn't it be cool to say
myrange.hasheader = true (first row of the range is the column name)
Or even better
myrange.columnnames = array("col1", "ColName"...) or
myrange.columnNames = Range("A1:N1")

This will give me a lot of flexibility - I can move the range to another
location with little effect on the code.
Also makes the code a little more self-documenting.

Thanks in advance
Habib




--
www.DynExtra.com
A resource for the Microsoft Dynamics Community
Featuring FAQs, File Exchange and more
Current member count: 40
--------------------------------------------
Share your knowledge. Add your favorite questions and answers
Help add questions to this site! We want Your input.
--------------------------------------------


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default RAnge as Table

if the workbook is closed, then you can reference your range using ADO and
treat it as a table thus utilizing SQL to manipulate/reference the data
therein.

--
Regards,
Tom Ogilvy


"HSalim[MVP]" wrote in message
...
Hi,
This question has probably been answered before.
I'm trying to use a range as a table, so that I can refer to columns be
their name

for example:
Set myrange = sheets("orders").Range("A10:N100")
For Each row in my range
myrange.ordertotal = myrange.subtotal + myrange.freight
Next

Wouldn't it be cool to say
myrange.hasheader = true (first row of the range is the column name)
Or even better
myrange.columnnames = array("col1", "ColName"...) or
myrange.columnNames = Range("A1:N1")

This will give me a lot of flexibility - I can move the range to another
location with little effect on the code.
Also makes the code a little more self-documenting.

Thanks in advance
Habib




--
www.DynExtra.com
A resource for the Microsoft Dynamics Community
Featuring FAQs, File Exchange and more
Current member count: 40
--------------------------------------------
Share your knowledge. Add your favorite questions and answers
Help add questions to this site! We want Your input.
--------------------------------------------




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default RAnge as Table

Tom,
Thanks for the reply. I know about ADO.
I was hoping there was a something similar in the XL VBA object model.
as a workaround, I created an enumeration, and use that for column names.

For example
enum Orders
OrderID = 4
customerID = 5
...
end enum
for rownum = 2 to Sheet("Orders").Range("D65536").End(xlUp).Row
x = cells(rownum, Orders.OrderID)

If there is a better way, I'd love to know.

Regards
Habib

--
www.DynExtra.com
A resource for the Microsoft Dynamics Community
Featuring FAQs, File Exchange and more
Current member count: 40
--------------------------------------------
Share your knowledge. Add your favorite questions and answers
Help add questions to this site! We want Your input.
--------------------------------------------
"Tom Ogilvy" wrote in message
...
if the workbook is closed, then you can reference your range using ADO and
treat it as a table thus utilizing SQL to manipulate/reference the data
therein.

--
Regards,
Tom Ogilvy


"HSalim[MVP]" wrote in message
...
Hi,
This question has probably been answered before.
I'm trying to use a range as a table, so that I can refer to columns be
their name

for example:
Set myrange = sheets("orders").Range("A10:N100")
For Each row in my range
myrange.ordertotal = myrange.subtotal + myrange.freight
Next

Wouldn't it be cool to say
myrange.hasheader = true (first row of the range is the column name)
Or even better
myrange.columnnames = array("col1", "ColName"...) or
myrange.columnNames = Range("A1:N1")

This will give me a lot of flexibility - I can move the range to another
location with little effect on the code.
Also makes the code a little more self-documenting.

Thanks in advance
Habib




--
www.DynExtra.com
A resource for the Microsoft Dynamics Community
Featuring FAQs, File Exchange and more
Current member count: 40
--------------------------------------------
Share your knowledge. Add your favorite questions and answers
Help add questions to this site! We want Your input.
--------------------------------------------






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
Pivot table and value range Nicawette Excel Discussion (Misc queries) 2 December 28th 09 09:09 AM
sorting data from one table/range to another table/range Danko Jotanovic Excel Discussion (Misc queries) 1 April 15th 09 01:06 PM
Given a VALUE in a table, ascertain RANGE in another table Paul Martin[_2_] Excel Discussion (Misc queries) 0 May 9th 08 06:25 AM
dynamic range with a table below the working table Robert H Excel Worksheet Functions 9 March 17th 08 01:41 PM
Mapping one table based on another table range waynehamilton Excel Worksheet Functions 7 May 12th 05 04:37 AM


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