+ Reply to Thread
Results 1 to 3 of 3

Scan through row 1 fields for specified text and record the column in a variable

  1. #1
    Registered User
    Join Date
    12-23-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2003
    Posts
    2

    Scan through row 1 fields for specified text and record the column in a variable

    Hello,

    I get a data file once a week, and I've built a macro to clean it as needed. Unfortunately, my original macro relied on the columns of the data provided to be in the same order each week, an assumption that has proved false.

    The code below is supposed to scan through the fields of row 1, find the one containing "source", and record that column in a variable called SourceColumn.
    Please Login or Register  to view this content.
    Every part of the above seems to work except [SourceColumn = Column]. For some reason, SourceColumn remains 65. I've attached the row that the above code is supposed to read. I appreciate any help anyone can give me, and I apologize in advance if I don't respond to your help quickly. I'm about to hop on a plane.

    Thanks so much!

    Will
    Attached Files Attached Files
    Last edited by wfogel; 12-28-2010 at 04:53 PM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Scan through row 1 fields for specified text and record the column in a variable

    I may be wrong but it is probably because you have declared Column as an Integer. I believe Column is a reserved word. I may be wrong and someone will correct me I'm sure. Try changing that to a different declaration.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Registered User
    Join Date
    12-23-2010
    Location
    Washington DC
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Scan through row 1 fields for specified text and record the column in a variable

    Thanks so much, Mordred. After I posted, I left for Christmas break, had a minor car accident, and in general forgot about this problem. My apologies for returning to it so late.

    I followed your suggestion and it worked. Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1