Elseif not being recognized in IF statement

carissa7

New Member
Joined
Jan 13, 2018
Messages
8
This statement --> ElseIf rng2.Value <> dstRng Then MsgBox rng2.Value & " not in RVP Group GAAP sheet" is not being recognized for some reason, and I made sure to set values not equal to each other. Basically I am trying to apply error handling to my if statement below. it works perfectly when the two ranges match just not when values do not match...


Code:
   Set wb2 = ThisWorkbook
   Set Ws2 = wb2.Sheets("Output - Flat")
   Set Ws1 = wb1.Sheets("RVP Local GAAP")
   Set rng = Range("CurrentTaxPerLocalGAAPProvision")
   Set rng2 = Range("CurrentTaxPerGroupGAAPProvision")
   Set ws1A = wb1.Sheets("RVP Group GAAP")
   Set ws3 = wb1.Sheets("Index")
   Ws2.Range("CorpTaxEntityName").Copy
   ws3.Range("D4").PasteSpecial xlPasteValues
   
   For Each rng2 In Ws2.Range("NamedRange")
      Set dstRng = Nothing
      On Error Resume Next
      Set dstRng = ws1A.Range(rng2.Value)
      On Error GoTo 0
      'Check that the range exists in destination sheet
      If Not dstRng Is Nothing Then
         'Check that the range exists in the appropriate area
         If Not Intersect(dstRng, ws1A.Range("CurrentTaxPerGroupGAAPProvision")) Is Nothing Then
            ''MsgBox "succesful"
            ''found = False
            'Transfer the value from the next column to the appropriate range in the
            'destination sheet
            dstRng.Value = rng2.Offset(0, 1).Value
         ElseIf rng2.Value <> dstRng Then
            MsgBox rng2.Value & " not in RVP Group GAAP sheet"
         End If
      End If
   Next
 
Last edited by a moderator:

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,214,786
Messages
6,121,548
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top