help to paste via visual basic

G

Guest

thanks for replying maybe i do need a VB sample.
Maybe I originally explained it To simply :(
Basically instead of hello i really want to print an address on a different
sheet(one address line per cell vertically) but i have about 100 different
addresses.
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
 
G

Guest

Try:

Sub ian()

Dim r1 As Range
Dim r2 As Range
Dim r3 As Range
Dim r4 As Range

Set r1 = Sheets("Sheet1").Range("A1")
Set r2 = Sheets("Sheet1").Range("A1:A5")
Set r3 = Sheets("Sheet2").Range("D1")
Set r4 = Sheets("Sheet2").Range("D10")

If r1.Value = 1 Then
r2.Copy r3
Else
If r1.Value = 54 Then
r2.Copy r4
End If
End If

End Sub

This has been coded for maximum clarity rather than least lines of code.
 

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