+ Reply to Thread
Results 1 to 4 of 4

Test if row 1 contains correct text VBA

  1. #1
    Forum Contributor
    Join Date
    08-17-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    158

    Test if row 1 contains correct text VBA

    Hello!

    I have a spreadsheet that is sent to me from one of my colleagues. I take this spreadsheet and format it a certain way to utilize further. The spreadsheet that I am sent has 39 differnt columns in it. Each column has its own respective field name that is SUPPOSED to be the same each time the file is sent to me. I would like to have some VBA code that goes through each cell in the first row to ensure the fields are correct. If the fields are correct, then have a msgbox pop up after the code has ran saying all fields are correct. If there is a cell that contains the incorrect field name, then the Msgbox should say STOP, FIELD NAME INCORRECT.

    A1 = "Team"
    B1 = "Single"
    C1 = "Other"
    D1 = "Month"
    E1 = "Year"
    F1 = "Day"
    etc.....

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Test if row 1 contains correct text VBA

    Hi

    Try this

    Please Login or Register  to view this content.
    rylo

  3. #3
    Forum Contributor
    Join Date
    08-17-2012
    Location
    Richmond, VA
    MS-Off Ver
    Excel 2007
    Posts
    158

    Re: Test if row 1 contains correct text VBA

    Awesome! Yep that works great. Now what I'd like to do with this is instead of the MsgBox telling me the value of the cell that is wrong, I'd like to know the address of the cell that is wrong. Also, if there is something wrong with one of the fields that is named, then end sub.

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Test if row 1 contains correct text VBA

    Hi

    I've recut the first sub so that it lists all the cells that have problems. I've also included a second sub that will go to the problem cell, give a message and end.

    Please Login or Register  to view this content.
    rylo

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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