Custom Code

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
Hi,

How could I write a macro code that would copy the range <code>"I11,M15,I10,I12,I15,M13,I14,K14,I13,O13" </code>from the active sheet if cell "I10" is not empty.


If the cell "I10" is empty How could the code be made to copy the range
<code>"I11,M15,D17,I12,I15,M13,I14,K14,I13,O13" from the active sheet.


Any help to do this please?</code><code></code>
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Take a look at this as an example

Sub test()
Dim i As Long
If Range("I10") <> "" Then
With ActiveSheet.Range("I11,M15,I10,I12,I15,M13,I14,K14,I13,O13")
For i = 1 To .Areas.Count
.Areas(i).Copy Sheets("sheet2").Range(.Areas(i).Address)
Next
End With
ElseIf Range("I10") = "" Then
With ActiveSheet.Range("I11,M15,D17,I12,I15,M13,I14,K14,I13,O13")
For i = 1 To .Areas.Count
.Areas(i).Copy Sheets("sheet2").Range(.Areas(i).Address)
Next
End With
End If

End Sub
 
Upvote 0
How could I write a macro code that would copy the range ..
Copy to where?

Is there a reason that you have listed all the cells individually and in a non-systematic way?
For example, in terms of the cells included
Range("I11,M15,I10,I12,I15,M13,I14,K14,I13,O13")
could also be written as
Range("I10:I15,K14,M13,M15,O13")
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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