+ Reply to Thread
Results 1 to 5 of 5

Copy cells and paste to an address given in another cell (VBA Newbie)

  1. #1
    Registered User
    Join Date
    08-30-2004
    Posts
    16

    Question Copy cells and paste to an address given in another cell (VBA Newbie)

    Can anyone help with this problem. I am trying write a macro to copy a range of cells on one worksheet, then goto an address which is specified in a cell. (This address is dynamic and changes according to the date) The data can then be copied to the new location. I am attaching a bitmap image of my example.

    Here are my required actions:
    Go to cell B27-B33 on worksheet "Entry Sheet"
    Copy cells B27-B33
    Go To the address in cell B20 (in this case Data!J29)
    Paste the copied cell

    Thanks in anticipation

    Rob
    Attached Files Attached Files

  2. #2
    Rowan Drummond
    Guest

    Re: Copy cells and paste to an address given in another cell (VBANewbie)

    Maybe like this:

    Sub CopyIt()
    Dim CTo As Range
    Dim CRng As String
    CRng = Sheets("Entry Sheet").Range("B20").Value
    Set CTo = Sheets(Left(CRng, InStr(1, CRng, "!") - 1)). _
    Range(Right(CRng, Len(CRng) - InStr(1, CRng, "!")))
    Sheets("Entry Sheet").Range("B27:B33").Copy CTo
    End Sub

    Hope this helps
    Rowan

    WightRob wrote:
    > Can anyone help with this problem. I am trying write a macro to copy a
    > range of cells on one worksheet, then goto an address which is
    > specified in a cell. (This address is dynamic and changes according to
    > the date) The data can then be copied to the new location. I am
    > attaching a bitmap image of my example.
    >
    > Here are my required actions:
    > Go to cell B27-B33 on worksheet "Entry Sheet"
    > Copy cells B27-B33
    > Go To the address in cell B20 (in this case Data!J29)
    > Paste the copied cell
    >
    > Thanks in anticipation
    >
    > Rob
    >
    >
    > +-------------------------------------------------------------------+
    > |Filename: DataCopyExample.doc |
    > |Download: http://www.excelforum.com/attachment.php?postid=3928 |
    > +-------------------------------------------------------------------+
    >


  3. #3
    Registered User
    Join Date
    08-30-2004
    Posts
    16

    Solved!

    Thanks Rowan,

    That did the trick.

    Rob


  4. #4
    Registered User
    Join Date
    08-30-2004
    Posts
    16

    Question A further problem

    As I said in my last post, the problem was solved. Unfortunately that was only with my simplfied example.

    In my actual workbook, the values in the range B27:B33 are fed in from a calculator sheet. Rowan's code is copying the actual cell data, which is now setting up a link to the calculator sheet. What I need is a "Paste Special" = Value, rather that a simple "Paste", is this possible?

    I am new to VBA coding, so all help is appreciated.

    Rob

  5. #5
    Rowan Drummond
    Guest

    Re: Copy cells and paste to an address given in another cell (VBANewbie)

    Hi Rob

    Try:

    Sub CopyIt()
    Dim CTo As Range
    Dim CRng As String
    CRng = Sheets("Entry Sheet").Range("B20").Value
    Set CTo = Sheets(Left(CRng, InStr(1, CRng, "!") - 1)). _
    Range(Right(CRng, Len(CRng) - InStr(1, CRng, "!")))
    Sheets("Entry Sheet").Range("B27:B33").Copy
    CTo.PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
    End Sub

    Regards
    Rowan

    WightRob wrote:
    > As I said in my last post, the problem was solved. Unfortunately that
    > was only with my simplfied example.
    >
    > In my actual workbook, the values in the range B27:B33 are fed in from
    > a calculator sheet. Rowan's code is copying the actual cell data,
    > which is now setting up a link to the calculator sheet. What I need is
    > a "Paste Special" = Value, rather that a simple "Paste", is this
    > possible?
    >
    > I am new to VBA coding, so all help is appreciated.
    >
    > Rob
    >
    >


+ 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