Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA, use the second row as the field name 1

Status
Not open for further replies.

jslmvl

Vendor
Jan 26, 2008
268
GB
Hi,

In Excel, we can treat a sheet as a database table and the first row would be the field name.
Can we ignore the first rwo and use the second row as the field name?
 



hi,

Not that I am aware of?

Please explain your issue in more depth.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thank you.

That is because the sheet has got titles in two rows: first row is main titles and the second is sub-titles. I want to use the sub-titles as the field names and don't want to change the sheet.
 


Copy the sheet to another sheet and delete row 1 on that sheet.

However, 2 heading rows is NOT standard for a table. Therefore, your "table" is really NOT one!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Excel has never dealt with that very well. Unless you're doing something progammatically similar to what Skip has already said, it's pretty much going to use the first row for column headings or not and those are your choices.

This is annoying when importing someone else's data who doesn't understand this issue. If it's data from somewhere else that you're importing, I have had better luck asking the person sending me data to give me a hidden first row that has the real column names in it and the 2nd row is visible to everybody else.

Excel will attempt to use the first row even if it's hidden row as I recall.
 
the sheet has got titles in two rows: first row is main titles and the second is sub-titles. I want to use the sub-titles as the field names and don't want to change the sheet.
In that situation I simply insert a blank row between the two title rows, then hide it.




Gavin
 


sheet as a database table
Hiding rows or inserting rows does not change the fact that as a database table, ROW 1 IS the heading row.

The thing that you could so is give the range from row 2 down a range name and the query using that name. That you cause absolutely not physical change to the sheet.
Code:
then in your query, use the name database rather than the [sheet name$]

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top