Defining a range of cells when the cell numbers are unkown

Mhaggerty

New Member
Joined
Aug 8, 2011
Messages
4
I need to copy and paste a range of data that is consistent but the starting cell changes. The format of the data is always the same, which is why I can always find the header "Total Units" but how do I then define teh range of data that I want to copy? I need to copy about 8 lines of data under the header, but I will not know the cell numbers.


Workbooks.Open Filename:= _<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
"C:\Macro\Calculator\Pending Activity 60 days\7 building.xls"<o:p></o:p>
Cells.Find(What:="total units", After:=ActiveCell, _<o:p></o:p>
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _<o:p></o:p>
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=True).Activate<o:p></o:p>
ActiveCell.Offset(7, 0).Select This is always the start of the range
Here is where I’d like to define a range of cells the column as the cell numbers may change and I only want to paste a selection of 8 cells.
Selection.Copy<o:p></o:p>
ActiveSheet.Paste<o:p></o:p>
Application.CutCopyMode = False<o:p></o:p>
Windows("occupancy data.xlsm").Activate<o:p></o:p>
Range("B4").Select<o:p></o:p>
ActiveSheet.Paste<o:p></o:p>
Application.CutCopyMode = False<o:p></o:p>
With Selection<o:p></o:p>
.WrapText = False<o:p></o:p>
.Orientation = 0<o:p></o:p>
.AddIndent = False<o:p></o:p>
.ShrinkToFit = False<o:p></o:p>
.ReadingOrder = xlContext<o:p></o:p>
.MergeCells = False
End With

<o:p></o:p>
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

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