PDA

View Full Version : Named Ranges



LOSS1574
01-21-2009, 06:16 PM
Hi:

I need to combine two (2) different dynamic named ranges on two (2) worksheets into one range with a blank row inbetween the data on a new worksheet (worksheet 3)..

Any assistance is appreaciated

mdmackillop
01-21-2009, 06:28 PM
Sub CopyRanges()
Range("DynRange1").Copy Sheets(3).Range("A1")
Range("DynRange2").Copy Sheets(3).Cells(Rows.Count, 1).End(xlUp).Offset(2)
End Sub

LOSS1574
01-21-2009, 06:52 PM
Thanks how can i adust the code to add data in colums M:P in the worksheet 3?

Range("M1:P" & Rows.Count).End(xlDown) ??? Am I in the ballpark?

Bob Phillips
01-22-2009, 03:09 AM
Surely, the name caters for that. 6 columns cover as many rows as one column.

mdmackillop
01-22-2009, 05:32 AM
There is a potential problem if the first column is shorter than the others in a multi-column range. This revision should cater for that.

Sub CopyRanges()
Range("DynRange1").Copy Sheets(3).Range("M1")
Range("DynRange2").Copy _
Sheets(3).Range("M1").Offset(Range("DynRange1").Rows.Count + 1)
End Sub