Searching a row A for 2 values - how to extend to Row U and copy + paste those to new sheet?

anon500

New Member
Joined
Jul 17, 2020
Messages
11
I have data pull that I would like to arrange and sort by finding 'tables' in the sheet and copying and pasting those tables out to different sheets

Sub SelectBetween()
On Error GoTo errhandler
Dim FinalRow As Integer

Worksheets("Dump").Activate
Range(Range("A:A").Find("test1").Offset(1), Range("A:A").Find("test2", Range("A:A").Find("test1")).Offset(-1)).Select
FinalRow = Cells(Rows.Count, "C").End(xlUp).Row
Selection.Copy
Worksheets("Sheet2").Activate
ActiveSheet.Paste
Application.CutCopyMode = False
Exit Sub
errhandler:
MsgBox "No Cells containing specified text found"
End Sub

So above searches Sheet 'Dump' finds Test 1 to Test 2 table, copies only Range A1 and pastes into the cell I'm hovered over, how could this be changed to paste into Range A1?

The FinalRow = Cells(Rows.Count, "C").End(xlUp).Row doesn't do anything yet, I need to figure out how to put this into my code, I was trying to get it to select till final row instead of only Row A

Very bad coding practices probably!
 
Last edited by a moderator:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Fourth occurrence from the bottom up or Fourth occurrence from the top down?
 
Upvote 0
Fourth from the top down, or first occurence from the bottom up - I think maybe if you can do the second one it would help me understand the code a little :)
 
Upvote 0
or first occurence from the bottom up
Would have saved a lot of code writing if you had asked for this in your previous post rather than the fourth occurrence :rolleyes:
VBA Code:
Set erow = Worksheets("Dump").Columns("A").Find("Test2", , xlValues, xlWhole, xlByRows, xlPrevious)
 
Upvote 0
Would have saved a lot of code writing if you had asked for this in your previous post rather than the fourth occurrence :rolleyes:
VBA Code:
Set erow = Worksheets("Dump").Columns("A").Find("Test2", , xlValues, xlWhole, xlByRows, xlPrevious)

Thank you so much.

I am truly sorry....
 
Upvote 0
Happy it helped and welcome to the forum.
 
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,676
Members
448,977
Latest member
moonlight6

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