+ Reply to Thread
Results 1 to 3 of 3

help to copy and paste with VB

  1. #1
    ian123
    Guest

    help to copy and paste with VB

    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

  2. #2
    Chip Pearson
    Guest

    Re: help to copy and paste with VB

    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



    "ian123" <[email protected]> wrote in message
    news:[email protected]...
    >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




  3. #3
    Chip Pearson
    Guest

    Re: help to copy and paste with VB

    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

    "Chip Pearson" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >
    >
    >
    > "ian123" <[email protected]> wrote in message
    > news:[email protected]...
    >>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

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1