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!

Column names changing in a linked spreadsheet

Status
Not open for further replies.

tbtcust

Programmer
Oct 26, 2004
214
US
Hello everyone. I have an excel spreadsheet linked as a table in a database. I have several queries that use this table. The column names in the linked spreadsheet is constantly changing, which is impacting all the queries. Columns are constantly being added and deleted as well.

Can someone recommend a method or two that I can use to reduce impact on the queries?

Thanks in advance for any help.
 
Are these changes just mysteriously happening or is someone opening the spreadsheet and changing things?
 
Sometimes in Excel VBA, I use “Enum” to define what column certain data is in. Then you only have to change a number when the column moves. If it is deleted, you still might be in trouble:
Code:
Public Enum TheColumns
    CustomerID=1
    CustomerName=2
    Brand=3
End Enum

sub DoSomething()
    For N = 2 To CtRows
        Workbooks(fName).Activate
        Select Case Cells(N, TheColumns.Brand)   'Refers to current Row and Col 3
Not perfect but might help


Alan
[smurf]
 
Thanks everyone for your suggestions.

Did some reading on other sites and came up with the notion of a data access layer, which amounts to a set of select queries against the linked spreadsheet. I have standard names in the DA queries. Other queries, reports, etc, use the DA queries. Now when there is a change to the linked spreadsheet I update the DA queries and there is no impact downstream.

Thanks again everyone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top