Results 1 to 9 of 9

Thread: Why is this code returning a Runtime error 13 Type mismatch?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Aug 2015
    Posts
    5
    Rep Power
    0

    Why is this code returning a Runtime error 13 Type mismatch?

    This macro is looking at two cells (A8 and A10) to determine if the values are there in both cells or only one cell.
    If the values are in both cells C11 get a value of 2
    If the value is in only one cell C11 gets a value of 1
    I do need to add a third option where if the valuse in the code below are not found in either cell C11 gets a value of 0.

    The text in red in the code, shows where the error occures.
    All cells on Sheet1 and PART are formatted as General. There are no extra spaces or characters in the cells where the data is being pulled from. I am stumped and I hope someone can help.

    Code:
     ' Part quantity being determined
            Dim Val1 As String
            Dim Val2 As String
            Val1 = Sheet1.Range("A8")
            Val2 = Sheet1.Range("A10")
            If Val1 = "-A" Or "-B" Or "-H" _
            And Val2 = "-A" Or "-B" Or "-H" Then
                Sheet1.Range("C11").Value = 2
                Sheets("PART").Range("B35:E35").Copy Destination:=Sheet1.Range("A11")
            Else
                Sheet1.Range("C11").Value = 1
            
            End If

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgyG714V_k7odQMrTz14AaABAg. 9h740K6COOA9iHOYYpaAbC
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgxuL6YCUckeUIh9hoh4AaABAg
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgwGTEyefOX7msIh1wZ4AaABAg. 9h4sd6Vs4qE9h7G-bVm8_-
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=Ugw3nF0C04AGt73H1BB4AaABAg. 9h6VhNCM-DZ9h7EqbG23kg
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgwGTEyefOX7msIh1wZ4AaABAg. 9h4sd6Vs4qE9h7KvJXmK8o
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=Ugw3nF0C04AGt73H1BB4AaABAg. 9h6VhNCM-DZ9h7E1gwg4Aq
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgywFtBEpkHDuK55r214AaABAg
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgwviLabd7r_3KpP6wh4AaABAg. 9h5lFRmix1R9h79hNGvJbu
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgwviLabd7r_3KpP6wh4AaABAg. 9h5lFRmix1R9h79YAfa24T
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgwviLabd7r_3KpP6wh4AaABAg. 9h5lFRmix1R9h79M1SYH1E
    https://www.youtube.com/watch?v=2oT4qrHmDMY&lc=UgwviLabd7r_3KpP6wh4AaABAg. 9h5lFRmix1R9h78SxhXTnR
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 07-09-2023 at 10:53 PM.

Similar Threads

  1. VBA Code Breaks During Runtime But Not In Debug Mode
    By xander1981 in forum Excel Help
    Replies: 14
    Last Post: 04-10-2014, 08:29 PM
  2. Excel VBA Run-time error '13' Type mismatch
    By mackypogi in forum Excel Help
    Replies: 5
    Last Post: 09-17-2013, 11:16 AM
  3. Export outlook emails to Excel code Error
    By jamilm in forum Outlook Help
    Replies: 2
    Last Post: 02-22-2013, 03:48 PM
  4. Runtime Error 481 invalid figure when PNG
    By Tony in forum Excel Help
    Replies: 0
    Last Post: 02-12-2013, 12:59 AM
  5. MLookup not returning results
    By jomili in forum Excel Help
    Replies: 5
    Last Post: 12-20-2012, 09:16 PM

Posting Permissions

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