Copy range from Sheet1 into empty range in Sheet2

B

Buddy

I am always copying range C2:p5 from Sheet1, however the range I am pasting
it into in Sheet 2 will be any one of these ranges.

Ranges
C5:p8
C9:p12
C13:p16
C17:p20
C21:p24
C25:p28
C33:p36
C37:p40
C41:p44
C45:p48
C49:C52
C53:C56
C57:C60
C61:C64
C65:C67

Can you help me add to the macro below so that it searches these ranges from
top to bottom and pastes the contents into the first empty range without
contents?

Sub FindEmptyRange()
Sheets("Sheet2").Range("C5:p8").Value = _
Sheets("Sheet1").Range("C2:p5).Value
Sheets("Sheet2").Activate
End Sub

For example ideally the macro will check range C5:p8 on Sheet2 first. If
that range already has contents inside it then C9:p12 will be checked. If
that range is empty the contents will be pasted into it, if not, the macro
will go to the next range C13:C16, and so on.
 
J

Jim Cone

Dim arrRng As Variant
Dim vItem As Variant
arrRng = Array("C5:p8", "C9:p12", "C13:p16") '>> Add the other addresses
For Each vItem In arrRng
If Application.CountA(Worksheets("Sheet2").Range(vItem)) = 0 Then
Worksheets("Sheet2").Range(vItem).Value = _
Worksheets("Sheet1").Range("C2:p5").Value
Exit For
End If
Next
--
Jim Cone
Portland, Oregon USA





"Buddy" <[email protected]>
wrote in message
I am always copying range C2:p5 from Sheet1, however the range I am pasting
it into in Sheet 2 will be any one of these ranges.

Ranges
C5:p8
C9:p12
C13:p16
C17:p20
C21:p24
C25:p28
C33:p36
C37:p40
C41:p44
C45:p48
C49:C52
C53:C56
C57:C60
C61:C64
C65:C67

Can you help me add to the macro below so that it searches these ranges from
top to bottom and pastes the contents into the first empty range without
contents?

Sub FindEmptyRange()
Sheets("Sheet2").Range("C5:p8").Value = _
Sheets("Sheet1").Range("C2:p5).Value
Sheets("Sheet2").Activate
End Sub

For example ideally the macro will check range C5:p8 on Sheet2 first. If
that range already has contents inside it then C9:p12 will be checked. If
that range is empty the contents will be pasted into it, if not, the macro
will go to the next range C13:C16, and so on.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top