PDA

View Full Version : [SOLVED] VBA: If And Then Else Run-Time error '13'



Bnagel
03-13-2020, 05:41 AM
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...

Bnagel
03-13-2020, 08:33 AM
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.

Paul_Hossler
03-13-2020, 08:50 AM
Merged Cells can be tricky and a lot of people don't like to use them

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