help to copy and paste with VB

G

Guest

I need help to do the following
i need to copy and paste adresses from on sheet to another depending on the
cell value
EXAMPLE:

IF cell a2 on sheet 1 says "1" then copy the address (cells a1 to a5 on sheet
1) to cells d1 to d5 on sheet 2

if cell A2 on sheet 1 says "54" then copy THAT address (cells a1 to a5 on
sheet 1) to cells d10 to d15 on sheet 2
ANYONES HELP WOULD BE VERY APPRECIATED thanks
 
C

Chip Pearson

I'm not entirely clear what you want to do, but you might try
some code like

Select Case Worksheets("Sheet2").Range("A2").Value
Case 1
Range("A1:A5").Copy
Destination:=Worksheets("Sheet2").Range("D1")
Case 54
Range("A1:A5").Copy
Destination:=Worksheets("Sheet2").Range("D10")
End Select



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
C

Chip Pearson

The code got line-wrapped in the post. The Destination argument
should be on the same line as Copy.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

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