Help with Excel Macro selecting range

largeselection

Active Member
Joined
Aug 4, 2008
Messages
358
Hi,

So I have some code but I need to select a certain range to copy/paste into a different workbook.

How can I have it copy a section above where it finds a specific value in a column?

So I want to code to copy from A9:J9 and all the way down until 2 rows above the row where the word "TOTAL" is found in Column A.

So would it be something like Range("A9:J & Find("TOTAL",A:A).offset(-2)

?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
If the cell above "TOTAL" is empty you could do this:-
Code:
Range("A9:J" & Range("A9").End(xlDown).Row).Select
Based on your code, this should work:-
Code:
Dim oRange As Range
Set oRange = Columns("A").Find(What:="TOTAL", LookIn:=xlValues, LookAt:=xlWhole)
Range("A9:J" & CStr(oRange.Row - 2)).Select
 
Upvote 0

Forum statistics

Threads
1,215,402
Messages
6,124,708
Members
449,182
Latest member
mrlanc20

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