Consulting

Results 1 to 3 of 3

Thread: VBA: If And Then Else Run-Time error '13'

  1. #1
    VBAX Newbie
    Joined
    Mar 2020
    Posts
    2
    Location

    VBA: If And Then Else Run-Time error '13'

    First time posting here. I am having an issue running this block of code:

    Private Sub Macro11(ByVal Target As Range)
    'requested pcb
    
    If Range("data_7670_100_v1.1_jp6_select").Value = "Open" And Range("data_7670_100_v1.1_jp7_select").Value = "Open" Then
    Application.EnableEvents = False
    Range("data_7670_100_v1.1_ai_b2_select").Value = "0-5v"
    Application.EnableEvents = True
    Else
    Application.EnableEvents = False
    Range("data_7670_100_v1.1_ai_b2_select").Value = "Select"
    Application.EnableEvents = True
    End If

    This code runs in several other Private Subs and all I am changing is the named ranges that its looking at for their value.
    I have verified that each named range is correctly named and there is no miss spelling.

    Any help would be greatly appreciated. This has me scratching my head, why does it work in one location but not another...
    Last edited by Bnagel; 03-13-2020 at 07:08 AM.

  2. #2
    VBAX Newbie
    Joined
    Mar 2020
    Posts
    2
    Location
    After taking a short break to clear my mind, i looked at all my named ranges and the "Value" column, it seems that it grabbed a range of sells before they were merged. Once i removed the second value and left it with just one cell everything started working.

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Merged Cells can be tricky and a lot of people don't like to use them

    You can mark this [Solved] -- see my sig
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Tags for this Thread

Posting Permissions

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