Overflow error even with Long variables

adamvas69

New Member
Joined
Apr 24, 2018
Messages
6
Hello, I'm VBA rookie and i need help from you, VBA Wizards :biggrin: I have this code:
Code:
Sub roztrideni()
Dim PosledniPlnyRadek as Long
Dim i As Long
'Rows("1:22").EntireRow.Delete
PosledniPlnyRadek = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To PosledniPlnyRadekIf Cells(i, 1) = "Air Bank a.s. / Evropská 2690/17 / 160 00 Praha 6 / IC 29045371 / BIC AIRACZPP" Then
Rows(i).EntireRow.Delete
Rows(i - 2).EntireRow.Clear
Rows(i - 3).EntireRow.Clear
Rows(i + 1).EntireRow.Clear
Rows(i + 2).EntireRow.Clear
Rows(i + 3).EntireRow.Clear
Rows(i + 4).EntireRow.Clear
Rows(i + 5).EntireRow.Clear
Rows(i + 6).EntireRow.Clear
Rows(i + 7).EntireRow.Clear
i = i - 10
End If
Next i
End Sub
And when i started macro i get a overflow error. I googled and i found advices only about not using Integer variables, but i'm using Long and my data set has only about 1000 rows. Can anybody help me, please? Thank you very much!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
SOLVED: Problem was in If Cells(i, 1) = "Text" , solution is adding Text, so it will look like this: If Cells(i, 1).Text = "Text"
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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