Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Editing While Using Column Headers As A Reference

I need to pull certain columns out of a data file to use in the creation of
an invoice. The file is a database export and the database will only pull
user-defined fields if they have data entered in them. Since we can use the
UDF fields some weeks and not others the data size is variable both in number
of row and in the columns that are created. I need to be able to select
columns based on their column header (Customer Number, Customer Name, Part
Number, etc).

Is there VBA language that will allow me to select a variable range based on
the column header?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Editing While Using Column Headers As A Reference

You can get the column number of a given column header like this...

ColNumber = Rows(1).Find("Part Number", LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=False).Column

where I assumed Row 1 contained the headers and, for the above example, that
we were looking for the Part Number header. You can use the found column
number in a Cells property call for a given row number to specify the
contents of that particular cell.

--
Rick (MVP - Excel)


"Have_Data_Will_Travel" wrote
in message ...
I need to pull certain columns out of a data file to use in the creation of
an invoice. The file is a database export and the database will only pull
user-defined fields if they have data entered in them. Since we can use
the
UDF fields some weeks and not others the data size is variable both in
number
of row and in the columns that are created. I need to be able to select
columns based on their column header (Customer Number, Customer Name, Part
Number, etc).

Is there VBA language that will allow me to select a variable range based
on
the column header?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Editing While Using Column Headers As A Reference

I'm not sure I understand. Where do I actually "get" the column number with
this code? Do I need to make it part of a message box or something?

What I want to do is to have a template with the headers I'm looking for and
search the raw data for the data under those columns. I could probably do it
with hlookups but it would take thousands of them.

"Rick Rothstein" wrote:

You can get the column number of a given column header like this...

ColNumber = Rows(1).Find("Part Number", LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=False).Column

where I assumed Row 1 contained the headers and, for the above example, that
we were looking for the Part Number header. You can use the found column
number in a Cells property call for a given row number to specify the
contents of that particular cell.

--
Rick (MVP - Excel)


"Have_Data_Will_Travel" wrote
in message ...
I need to pull certain columns out of a data file to use in the creation of
an invoice. The file is a database export and the database will only pull
user-defined fields if they have data entered in them. Since we can use
the
UDF fields some weeks and not others the data size is variable both in
number
of row and in the columns that are created. I need to be able to select
columns based on their column header (Customer Number, Customer Name, Part
Number, etc).

Is there VBA language that will allow me to select a variable range based
on
the column header?


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Editing While Using Column Headers As A Reference

From the Column property of the range that the Find function returns. This part...

Rows(1).Find("Part Number", LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)

returns the cell in Row 1 containing the text "Part Number" as a range... the .Column I placed after it in my original code pulls out the column number and (again, in my original code) I then assigned this column number to a variable which I named ColNumber for my example. You can assign it to any variable you want, or use it for the column argument in a Cells property call, or use it as the argument to a MsgBox statement, etc., etc.

--
Rick (MVP - Excel)


I'm not sure I understand. Where do I actually "get" the column number with
this code? Do I need to make it part of a message box or something?

What I want to do is to have a template with the headers I'm looking for and
search the raw data for the data under those columns. I could probably do it
with hlookups but it would take thousands of them.

"Rick Rothstein" wrote:

You can get the column number of a given column header like this...

ColNumber = Rows(1).Find("Part Number", LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=False).Column

where I assumed Row 1 contained the headers and, for the above example, that
we were looking for the Part Number header. You can use the found column
number in a Cells property call for a given row number to specify the
contents of that particular cell.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Editing While Using Column Headers As A Reference

Ahhh...I see. So I'm defining the variable so that I can use it in a code to
define the range that I want to copy and paste into my template.

"Rick Rothstein" wrote:

From the Column property of the range that the Find function returns. This part...

Rows(1).Find("Part Number", LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False)

returns the cell in Row 1 containing the text "Part Number" as a range... the .Column I placed after it in my original code pulls out the column number and (again, in my original code) I then assigned this column number to a variable which I named ColNumber for my example. You can assign it to any variable you want, or use it for the column argument in a Cells property call, or use it as the argument to a MsgBox statement, etc., etc.

--
Rick (MVP - Excel)


I'm not sure I understand. Where do I actually "get" the column number with
this code? Do I need to make it part of a message box or something?

What I want to do is to have a template with the headers I'm looking for and
search the raw data for the data under those columns. I could probably do it
with hlookups but it would take thousands of them.

"Rick Rothstein" wrote:

You can get the column number of a given column header like this...

ColNumber = Rows(1).Find("Part Number", LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=False).Column

where I assumed Row 1 contained the headers and, for the above example, that
we were looking for the Part Number header. You can use the found column
number in a Cells property call for a given row number to specify the
contents of that particular cell.


.

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
lookup using column headers and row headers Memphus01 Excel Discussion (Misc queries) 1 April 13th 09 04:57 PM
Hide Column Headers but not row (Headers) Kevan Gradwell Excel Programming 1 March 16th 07 05:59 PM
reference tabs in a summary sheet as column headers JDR Excel Discussion (Misc queries) 6 March 7th 07 06:04 PM
How do I reference Cell information in my Headers? P Alicea Excel Discussion (Misc queries) 2 October 27th 05 08:08 PM
Can you reference cell values in Headers and Footers in Excel 200. jkyte Excel Discussion (Misc queries) 2 December 30th 04 09:05 PM


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