mismatch 13/ Nested if

jamada

Active Member
Joined
Mar 23, 2006
Messages
323
Can someone explain why the second If (Nested) is causing a mismatch 13 error, and how to fix ?
Thank You
jamada



Dim LastRow As Long
Dim i As Long
LastRow = Range("B" & Rows.Count).End(xlUp).Row

For i = LastRow To 2 Step -1
If Cells(i, 2).Value > 0 Then
Range(Cells(i, 8), Cells(i, 12)).Offset(3).FormulaR1C1 = "=CONCATENATE(R[-2]C,"" "",LEFT(R[-1]C,1),""."")"
Range(Cells(i, 8), Cells(i, 12)).Offset(2).EntireRow.Delete
Range(Cells(i, 8), Cells(i, 12)).Offset(2).EntireRow.Delete
Range(Cells(i, 1), Cells(i, 7)).Cut Range(Cells(i + 1, 1), Cells(i + 1, 7))


If Range(Cells(i + 1, 8), Cells(i + 1, 12)).Value = Range(Cells(i + 1, 8), Cells(i + 1, 12)).Value Then
Range(Cells(i + 1, 8), Cells(i + 1, 12)).Interior.Color = RGB(146, 208, 80)
End If

End If
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Can someone explain why the second If (Nested) is causing a mismatch 13 error, and how to fix ?
Thank You
jamada



Dim LastRow As Long
Dim i As Long
LastRow = Range("B" & Rows.Count).End(xlUp).Row

For i = LastRow To 2 Step -1
If Cells(i, 2).Value > 0 Then
Range(Cells(i, 8), Cells(i, 12)).Offset(3).FormulaR1C1 = "=CONCATENATE(R[-2]C,"" "",LEFT(R[-1]C,1),""."")"
Range(Cells(i, 8), Cells(i, 12)).Offset(2).EntireRow.Delete
Range(Cells(i, 8), Cells(i, 12)).Offset(2).EntireRow.Delete
Range(Cells(i, 1), Cells(i, 7)).Cut Range(Cells(i + 1, 1), Cells(i + 1, 7))


If Range(Cells(i + 1, 8), Cells(i + 1, 12)).Value = Range(Cells(i + 1, 8), Cells(i + 1, 12)).Value Then
Range(Cells(i + 1, 8), Cells(i + 1, 12)).Interior.Color = RGB(146, 208, 80)
End If

End If
Yes, you cannot compare the values of multi-cell ranges at the one time. You would need to check each of the corresponding cells individually.

(In any case, aren't those two ranges actually the same range? That is, you are trying to compare a range with itself. :unsure:)
 
Upvote 0
Hi Peter, YES I was suppose to compare with the next row down as follows"

If Range(Cells(i + 1, 8), Cells(i + 1, 12)).Text = Range(Cells(i + 2, 8), Cells(i + 2, 12)).Text Then
Range(Cells(i + 1, 8), Cells(i + 1, 12)).Interior.Color = RGB(146, 208, 80)
End If

I also changed value to text, however I will code to check individually as you suggested.
Thank You
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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