Results 1 to 3 of 3

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

Threaded View

wfogel Scan through row 1 fields for... 12-23-2010, 12:59 PM
Mordred Re: Scan through row 1 fields... 12-23-2010, 01:06 PM
wfogel Re: Scan through row 1 fields... 12-28-2010, 04:49 PM
  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.
    
    Sub CANVASS_MANIPULATION()
    
    Dim SourceColumn As Integer
    Dim Column As Integer
    SourceColumn = 65
    Column = 65
    
    Do While SourceColumn = 65
    Range("O1").Value = Range(Chr(Column) & "1").Value
    Range("O3").Value = Column
    If Range(Chr(Column) & "1").Value = "SOURCE" Then
        SourceColumnn = Column
        Range("O2").Value = "SUCCESS"
        Range("O4").Value = SourceColumn
    End If
    Column = Column + 1
    Loop
    end sub()
    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.

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