VBA copy/paste error

rharn

Board Regular
Joined
Jun 21, 2011
Messages
54
Hello, I am trying to create a code that will copy and paste the results of an array from a search function onto a worksheet. However, I am getting an 'overflow' error when I try to use a copy/paste code that has worked for me in the past. Can someone please help me figure out why this paste function crashes when it gets to the last line of 'ActiveSheet.Paste'?

Code:
        For i1 = LBound(Results1) To UBound(Results1)
            Set p1results = Range(Results1(i1))
            Range("D" & p1results.Value & ":P" & p1results.Value).Copy
            Sheets("SearchResult").Select
            NextRow = Range("D65536").End(xlUp).Row + 1
            Cells(NextRow, 1).Select
            ActiveSheet.Paste
        Next i1
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi, VoG thanks for suggestion, but even afterI change it to 'Long' i am still receiving the error. Any other explanations? Thanks in advance!
 
Upvote 0
Does this work?

Code:
       For i1 = LBound(Results1) To UBound(Results1)
            Set p1results = Range(Results1(i1))
            Range("D" & p1results.Value & ":P" & p1results.Value).Copy Destination:=Sheets("SearchResult").Range("D" & Rows.Count).End(xlUp).Offset(1, -3)
        Next i1
 
Upvote 0
VoG I just realized why it won't work but do not have a simple solution perhaps you can provide. The array Results1() provides the cell addresses from a search function that I created. As a result, I want to display the results of each cell from the search array along with the subsequent data associated with the found cell location that ranges from columns D:P. Is there a way to just extract the number from the cell or anything of that sort? Thanks in advance!
 
Upvote 0

Forum statistics

Threads
1,215,492
Messages
6,125,115
Members
449,206
Latest member
burgsrus

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