+ Reply to Thread
Results 1 to 4 of 4

Simple Question, Getting an error and don't know why

  1. #1
    Registered User
    Join Date
    05-21-2013
    Location
    MTL
    MS-Off Ver
    Excel 2007
    Posts
    16

    Simple Question, Getting an error and don't know why

    Hello everyone,

    I have this if statement that keeps returning a "Run Time" error 13 (type mismatch), and I can't figure out why.

    Here it is (embedded in a for loop)

    /*For i = 6 To 2000
    If Cells(i, 5).Value = tr.Cells(x, 7).Value And Cells(i, 4).Value = tr.Cells(x, 4).Value Then
    outcome = "TRUE"
    End If
    Next i
    */

    I have initialized my variables like such:

    x = 3
    Dim i As Integer
    Set tr = Sheets("TRACKING")


    Does anyone know why this is happening?

    Thanks a lot,

    Corentin

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Simple Question, Getting an error and don't know why

    Do you have any error values in column D, E, or G?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    05-21-2013
    Location
    MTL
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Simple Question, Getting an error and don't know why

    No I don't have any errors, but I think I might know what's wrong now. I have both numerical and text values in all columns (because of headers, all the rest are numbers). Therefore I think vba can't compare Values in each column. What I did for now is simply use other columns that contain only text by storing the numbers as strings. It works but I don't know why the original idea wouldn't, considering I start my loop at x=3, which is the first row of numbers, after the headers...

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Simple Question, Getting an error and don't know why

    VBA can compare text and numbers.

+ 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