Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50061

Run Time Error '6' Overflow - Macro That Find Text and Copy Range & Replace on Other Sheet

$
0
0
Hi Guys!

I have a data sheet "Data Oil Urban" having more than 30,000 records in 7 columns in excel 2003. I have developed a form in the sheet named "Oil Urban" with combo boxes to filter data. all filters develop a combined 'string'. a command button runs a macro which finds the 'string' generated from filters from combo boxes from "Oil Urban" and matches with the 'string' in the sheet "Data Oil Urban" column A then copy a range of data from Sheet "Data Oil Urban" and replace on Sheet "Oil Urban" as a filter result.

The problem is that the macro for find replace works well to the 30,000 thousand rows but it gives a "run time error '6' Overflow" for the data which comes after 30 thousand rows.

I am attaching the code below and will be highly thankful for the resolution.

Regards,
Hussaini


Private Sub CommandButton1_Click()

Dim s As String, str1, str2, str3, str4, str5 As String
With Worksheets("Oil Urban")

str1 = Range("a3").Value
str2 = Range("a4").Value
str3 = Range("a5").Value
str4 = Range("a6").Value

s = str1 + str2 + str3 + str4
.Range("A7") = s

With Worksheets("Data Oil Urban").Columns("A")
Dim f1 As Integer, zaman1 As String
Para1:
Set c = .Find(s, LookIn:=xlValues)
If Not c Is Nothing Then
firstaddress = c.Row
'MsgBox "Row number of the result string is" & c.Row
'MsgBox "Row number of the result string is" & firstaddress
Do
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Row <> firstaddress
Else
MsgBox "Not found"
GoTo Para3
End If
Para2:
f1 = firstaddress
Worksheets("Data Oil Urban").Range(.Cells(f1, 7), .Cells(f1 + 26, 6)).Copy
End With

ActiveSheet.Paste Destination:=Worksheets("Oil Urban").Cells(12, 3)

Para3:

Worksheets("Oil Urban").Cells(12, 3).Select

End With
End Sub

Viewing all articles
Browse latest Browse all 50061

Trending Articles