Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Syntax for using table and column names

I can't figure out the syntax to use table and column names.

Assume I have a worksheet named "ClubMembers" containing a table named
"Members" with columns "Name" and "Number". Here is a simplified snippet
illustrating a dumb way to refer to them. How do I use table and column
names more elegantly?

Dim oListRow As ListRow
For Each oListRow In _
Worksheets("ClubMembers").ListObjects("Members").L istRows
oListRow.Range.Cells(1, 1) = "No Name"
oListRow.Range.Cells(1, 2) = 0
Next oListRow

Thanks for your help,

Jim Thompson





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Syntax for using table and column names

Depends on what you are trying to do. Maybe...
'--
Sub EOQ()
ActiveSheet.ListObjects(1).Range.Columns(1).Value = "No Name"
ActiveSheet.ListObjects(1).Range.Columns(2).Value = 0
End Sub
'--
Curious... did you publish the list in order to name it, use code or something else?
--
Jim Cone
Portland, Oregon USA



"James O. Thompson"

wrote in message
I can't figure out the syntax to use table and column names.

Assume I have a worksheet named "ClubMembers" containing a table named
"Members" with columns "Name" and "Number". Here is a simplified snippet
illustrating a dumb way to refer to them. How do I use table and column
names more elegantly?

Dim oListRow As ListRow
For Each oListRow In _
Worksheets("ClubMembers").ListObjects("Members").L istRows
oListRow.Range.Cells(1, 1) = "No Name"
oListRow.Range.Cells(1, 2) = 0
Next oListRow

Thanks for your help,
Jim Thompson





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Syntax for using table and column names

I was wanting to use Column Names instead of absolute numbers so that future
modifications to the structure of the table would not cause the code to
fail. In the example you gave me I know I could use the table name such as:

ActiveSheet.ListObjects("Members").Range.Columns(1 ).Value = "No Name"

But, for example, if later mods swapped the order of the columns the code
would fail since they are absolute. The following kind of illustrates what
I want to happen but gives a syntax error on compilation:

ActiveSheet.ListObjects("Members").Range.Columns(" Name").Value = "No Name"

Thanks for replying,

Jim Thompson

P.S. I didn't understand your question about my reasons for "publishing"
the list.

"Jim Cone" wrote in message
...
Depends on what you are trying to do. Maybe...
'--
Sub EOQ()
ActiveSheet.ListObjects(1).Range.Columns(1).Value = "No Name"
ActiveSheet.ListObjects(1).Range.Columns(2).Value = 0
End Sub
'--
Curious... did you publish the list in order to name it, use code or
something else?
--
Jim Cone
Portland, Oregon USA



"James O. Thompson"

wrote in message
I can't figure out the syntax to use table and column names.

Assume I have a worksheet named "ClubMembers" containing a table named
"Members" with columns "Name" and "Number". Here is a simplified snippet
illustrating a dumb way to refer to them. How do I use table and column
names more elegantly?

Dim oListRow As ListRow
For Each oListRow In _
Worksheets("ClubMembers").ListObjects("Members").L istRows
oListRow.Range.Cells(1, 1) = "No Name"
oListRow.Range.Cells(1, 2) = 0
Next oListRow

Thanks for your help,
Jim Thompson







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Syntax for using table and column names

Why don't you just name the data in each column of the list, something like...
"NumCol" and "NameCol" (excluding the headers, if any).
When data is added to the list the named range will automatically expand.
Same if the columns are moved.
So Range("NameCol").Value = "Sludge" will work in most cases.

I don't know how you are planning on rearranging the data or what
SharePoint might or might not do to the named ranges so you will have
test/experiment.
'--
My question was poorly put. I just want to know how you named the List?
--
Jim Cone
Portland, Oregon USA



"James O. Thompson" wrote in message ...
I was wanting to use Column Names instead of absolute numbers so that future
modifications to the structure of the table would not cause the code to
fail. In the example you gave me I know I could use the table name such as:

ActiveSheet.ListObjects("Members").Range.Columns(1 ).Value = "No Name"

But, for example, if later mods swapped the order of the columns the code
would fail since they are absolute. The following kind of illustrates what
I want to happen but gives a syntax error on compilation:

ActiveSheet.ListObjects("Members").Range.Columns(" Name").Value = "No Name"

Thanks for replying,

Jim Thompson

P.S. I didn't understand your question about my reasons for "publishing"
the list.

"Jim Cone" wrote in message
...
Depends on what you are trying to do. Maybe...
'--
Sub EOQ()
ActiveSheet.ListObjects(1).Range.Columns(1).Value = "No Name"
ActiveSheet.ListObjects(1).Range.Columns(2).Value = 0
End Sub
'--
Curious... did you publish the list in order to name it, use code or
something else?
--
Jim Cone
Portland, Oregon USA



"James O. Thompson"

wrote in message
I can't figure out the syntax to use table and column names.

Assume I have a worksheet named "ClubMembers" containing a table named
"Members" with columns "Name" and "Number". Here is a simplified snippet
illustrating a dumb way to refer to them. How do I use table and column
names more elegantly?

Dim oListRow As ListRow
For Each oListRow In _
Worksheets("ClubMembers").ListObjects("Members").L istRows
oListRow.Range.Cells(1, 1) = "No Name"
oListRow.Range.Cells(1, 2) = 0
Next oListRow

Thanks for your help,
Jim Thompson







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Syntax for using table and column names

The example you gave doesn't appear to set one cell in the column "NameCol"
to "Sludge". It would seem to set every cell in the entire column.
Apparently I'm not expressing the problem clearly. Let me start from
scratch:

Suppose I have a worksheet named "Club".
Suppose that worksheet has a table named "Members".
Suppose that table has a column with a header row label of "Lastname".

What Excel 2007 VBA statement(s) would I use to set the 5th (row 5) members
last name to "Thompson".

Thanks for taking time to work with me,

Jim Thompson

"Jim Cone" wrote in message
...
Why don't you just name the data in each column of the list, something
like...
"NumCol" and "NameCol" (excluding the headers, if any).
When data is added to the list the named range will automatically expand.
Same if the columns are moved.
So Range("NameCol").Value = "Sludge" will work in most cases.

I don't know how you are planning on rearranging the data or what
SharePoint might or might not do to the named ranges so you will have
test/experiment.
'--
My question was poorly put. I just want to know how you named the List?
--
Jim Cone
Portland, Oregon USA



"James O. Thompson" wrote in message
...
I was wanting to use Column Names instead of absolute numbers so that
future
modifications to the structure of the table would not cause the code to
fail. In the example you gave me I know I could use the table name such
as:

ActiveSheet.ListObjects("Members").Range.Columns(1 ).Value = "No Name"

But, for example, if later mods swapped the order of the columns the code
would fail since they are absolute. The following kind of illustrates
what
I want to happen but gives a syntax error on compilation:

ActiveSheet.ListObjects("Members").Range.Columns(" Name").Value = "No Name"

Thanks for replying,

Jim Thompson

P.S. I didn't understand your question about my reasons for "publishing"
the list.

"Jim Cone" wrote in message
...
Depends on what you are trying to do. Maybe...
'--
Sub EOQ()
ActiveSheet.ListObjects(1).Range.Columns(1).Value = "No Name"
ActiveSheet.ListObjects(1).Range.Columns(2).Value = 0
End Sub
'--
Curious... did you publish the list in order to name it, use code or
something else?
--
Jim Cone
Portland, Oregon USA



"James O. Thompson"

wrote in message
I can't figure out the syntax to use table and column names.

Assume I have a worksheet named "ClubMembers" containing a table named
"Members" with columns "Name" and "Number". Here is a simplified snippet
illustrating a dumb way to refer to them. How do I use table and column
names more elegantly?

Dim oListRow As ListRow
For Each oListRow In _
Worksheets("ClubMembers").ListObjects("Members").L istRows
oListRow.Range.Cells(1, 1) = "No Name"
oListRow.Range.Cells(1, 2) = 0
Next oListRow

Thanks for your help,
Jim Thompson











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Syntax for using table and column names


With Worksheets("Sludge")
.Range("Members").Cells(5,
Application.WorksheetFunction.Match("LastName", .Range("Members").Resize(1),
False)) = "Thomson"
End With

"James O. Thompson" wrote in message
...
The example you gave doesn't appear to set one cell in the column
"NameCol" to "Sludge". It would seem to set every cell in the entire
column. Apparently I'm not expressing the problem clearly. Let me start
from scratch:

Suppose I have a worksheet named "Club".
Suppose that worksheet has a table named "Members".
Suppose that table has a column with a header row label of "Lastname".

What Excel 2007 VBA statement(s) would I use to set the 5th (row 5)
members last name to "Thompson".

Thanks for taking time to work with me,

Jim Thompson

"Jim Cone" wrote in message
...
Why don't you just name the data in each column of the list, something
like...
"NumCol" and "NameCol" (excluding the headers, if any).
When data is added to the list the named range will automatically expand.
Same if the columns are moved.
So Range("NameCol").Value = "Sludge" will work in most cases.

I don't know how you are planning on rearranging the data or what
SharePoint might or might not do to the named ranges so you will have
test/experiment.
'--
My question was poorly put. I just want to know how you named the List?
--
Jim Cone
Portland, Oregon USA



"James O. Thompson" wrote in message
...
I was wanting to use Column Names instead of absolute numbers so that
future
modifications to the structure of the table would not cause the code to
fail. In the example you gave me I know I could use the table name such
as:

ActiveSheet.ListObjects("Members").Range.Columns(1 ).Value = "No Name"

But, for example, if later mods swapped the order of the columns the code
would fail since they are absolute. The following kind of illustrates
what
I want to happen but gives a syntax error on compilation:

ActiveSheet.ListObjects("Members").Range.Columns(" Name").Value = "No
Name"

Thanks for replying,

Jim Thompson

P.S. I didn't understand your question about my reasons for "publishing"
the list.

"Jim Cone" wrote in message
...
Depends on what you are trying to do. Maybe...
'--
Sub EOQ()
ActiveSheet.ListObjects(1).Range.Columns(1).Value = "No Name"
ActiveSheet.ListObjects(1).Range.Columns(2).Value = 0
End Sub
'--
Curious... did you publish the list in order to name it, use code or
something else?
--
Jim Cone
Portland, Oregon USA



"James O. Thompson"

wrote in message
I can't figure out the syntax to use table and column names.

Assume I have a worksheet named "ClubMembers" containing a table named
"Members" with columns "Name" and "Number". Here is a simplified
snippet
illustrating a dumb way to refer to them. How do I use table and column
names more elegantly?

Dim oListRow As ListRow
For Each oListRow In _
Worksheets("ClubMembers").ListObjects("Members").L istRows
oListRow.Range.Cells(1, 1) = "No Name"
oListRow.Range.Cells(1, 2) = 0
Next oListRow

Thanks for your help,
Jim Thompson









  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Syntax for using table and column names

I've found what I was looking for. To set the 5th members "LastName"in the
"Members" table to "Thompson" would look like:

Range("Members[LastName]").Cells(5,1) = "Thompson"

Thanks everyone for your help.

Jim Thompson


"Patrick Molloy" wrote in message
...

With Worksheets("Sludge")
.Range("Members").Cells(5,
Application.WorksheetFunction.Match("LastName",
.Range("Members").Resize(1), False)) = "Thomson"
End With

"James O. Thompson" wrote in message
...
The example you gave doesn't appear to set one cell in the column
"NameCol" to "Sludge". It would seem to set every cell in the entire
column. Apparently I'm not expressing the problem clearly. Let me start
from scratch:

Suppose I have a worksheet named "Club".
Suppose that worksheet has a table named "Members".
Suppose that table has a column with a header row label of "Lastname".

What Excel 2007 VBA statement(s) would I use to set the 5th (row 5)
members last name to "Thompson".

Thanks for taking time to work with me,

Jim Thompson

"Jim Cone" wrote in message
...
Why don't you just name the data in each column of the list, something
like...
"NumCol" and "NameCol" (excluding the headers, if any).
When data is added to the list the named range will automatically
expand.
Same if the columns are moved.
So Range("NameCol").Value = "Sludge" will work in most cases.

I don't know how you are planning on rearranging the data or what
SharePoint might or might not do to the named ranges so you will have
test/experiment.
'--
My question was poorly put. I just want to know how you named the List?
--
Jim Cone
Portland, Oregon USA



"James O. Thompson" wrote in message
...
I was wanting to use Column Names instead of absolute numbers so that
future
modifications to the structure of the table would not cause the code to
fail. In the example you gave me I know I could use the table name such
as:

ActiveSheet.ListObjects("Members").Range.Columns(1 ).Value = "No Name"

But, for example, if later mods swapped the order of the columns the
code
would fail since they are absolute. The following kind of illustrates
what
I want to happen but gives a syntax error on compilation:

ActiveSheet.ListObjects("Members").Range.Columns(" Name").Value = "No
Name"

Thanks for replying,

Jim Thompson

P.S. I didn't understand your question about my reasons for
"publishing"
the list.

"Jim Cone" wrote in message
...
Depends on what you are trying to do. Maybe...
'--
Sub EOQ()
ActiveSheet.ListObjects(1).Range.Columns(1).Value = "No Name"
ActiveSheet.ListObjects(1).Range.Columns(2).Value = 0
End Sub
'--
Curious... did you publish the list in order to name it, use code or
something else?
--
Jim Cone
Portland, Oregon USA



"James O. Thompson"

wrote in message
I can't figure out the syntax to use table and column names.

Assume I have a worksheet named "ClubMembers" containing a table named
"Members" with columns "Name" and "Number". Here is a simplified
snippet
illustrating a dumb way to refer to them. How do I use table and
column
names more elegantly?

Dim oListRow As ListRow
For Each oListRow In _
Worksheets("ClubMembers").ListObjects("Members").L istRows
oListRow.Range.Cells(1, 1) = "No Name"
oListRow.Range.Cells(1, 2) = 0
Next oListRow

Thanks for your help,
Jim Thompson










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
Add data to 2007 table based on column names? Tara H Excel Programming 0 May 28th 09 01:26 PM
Macro - Copy Table Column & Row Names When Codition Is Met steven.holloway Excel Discussion (Misc queries) 2 December 19th 07 04:08 PM
range names in macros - syntax again Dean[_8_] Excel Programming 5 September 21st 07 10:32 AM
Return a value from a table using Column and row names as input? Olle Excel Discussion (Misc queries) 7 November 23rd 06 05:55 PM
Add Database Names, table names & related fields from table in combo box Snowy Excel Programming 4 April 29th 06 01:08 PM


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