ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with overflow (https://www.excelbanter.com/excel-programming/344479-problem-overflow.html)

Peter

Problem with overflow
 
I want to search a column with one row indicator and for every row search
though another column and paste that value to the new (row,column) I have
tried this using two do-loops and one for each next-solution and one do loop
but I get an overflow problem. Can you help me?

Thanks.

/Peter

Private Sub cmdData2_Click()

Dim Counter As Integer
Dim Row101 As Integer
Dim Row102 As Integer
Dim Row111 As Integer
Dim Rad As Variant

Dim Col109 As Integer
Dim Col110 As Integer

Dim Col114 As Integer
Dim Col115 As Integer

Row101 = 1844

Row102 = 1844
Row111 = 2504
Counter = 1158

Col109 = 9
Col110 = 10
Col114 = 14
Col115 = 15

For Each Rad In Range(Cells(Row102, Col115), Cells(Row111, Col115))
Do
If Worksheets("Bure").Cells(Counter, Col109).Value =
Worksheets("Bure").Cells(Rad, Col114).Value Then
Range(Cells(Counter, Col110), Cells(Counter, Col110)).Copy
Range(Cells(Rad, Col115), Cells(Rad, Col115)).PasteSpecial
(xlPasteAll)
End If

Counter = Counter + 1

Loop Until Counter = 2505
Next

End Sub

Dave Peterson

Problem with overflow
 
First thing I'd do is change all those "As Integer" to "As Long".

Maybe that'll be enough.

Peter wrote:

I want to search a column with one row indicator and for every row search
though another column and paste that value to the new (row,column) I have
tried this using two do-loops and one for each next-solution and one do loop
but I get an overflow problem. Can you help me?

Thanks.

/Peter

Private Sub cmdData2_Click()

Dim Counter As Integer
Dim Row101 As Integer
Dim Row102 As Integer
Dim Row111 As Integer
Dim Rad As Variant

Dim Col109 As Integer
Dim Col110 As Integer

Dim Col114 As Integer
Dim Col115 As Integer

Row101 = 1844

Row102 = 1844
Row111 = 2504
Counter = 1158

Col109 = 9
Col110 = 10
Col114 = 14
Col115 = 15

For Each Rad In Range(Cells(Row102, Col115), Cells(Row111, Col115))
Do
If Worksheets("Bure").Cells(Counter, Col109).Value =
Worksheets("Bure").Cells(Rad, Col114).Value Then
Range(Cells(Counter, Col110), Cells(Counter, Col110)).Copy
Range(Cells(Rad, Col115), Cells(Rad, Col115)).PasteSpecial
(xlPasteAll)
End If

Counter = Counter + 1

Loop Until Counter = 2505
Next

End Sub


--

Dave Peterson


All times are GMT +1. The time now is 05:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com