+ Reply to Thread
Results 1 to 2 of 2

VBA pasting range from other workbook to cell B2 instead of A2

  1. #1
    Registered User
    Join Date
    07-04-2020
    Location
    Chicago, Illinois
    MS-Off Ver
    Microsoft 365 Personal
    Posts
    1

    VBA pasting range from other workbook to cell B2 instead of A2

    Hello,

    I'm brand new to VBA and have hobbled together some code but am having an issue.
    The goal is to copy a range of data from a table in a workbook and paste the range into cell A2 of a worksheet inside a different workbook.
    Both workbooks are stored in my One Drive > Documents folder.
    The code I currently have works with the exception being that it pastes the data into cell B2 rather than cell A2.

    Here's my current code:

    Sub CopyData()

    MIE = ThisWorkbook.Path & Application.PathSeparator & "MIE.xlsx"

    Dim wk As Workbook
    Set wk = Workbooks.Open(MIE, ReadOnly:=True)

    Dim rgSource As Range, rgDestination As Range

    Set rgSource = wk.Worksheets("Transactions").Range("A7:F12")
    Set rgDestination = ThisWorkbook.Worksheets("Import").Range("A2")

    rgSource.Copy
    rgDestination.PasteSpecial xlPasteValues

    End Sub

    I have looked all over to find a solution to this issue but can't figure this out. Any help is greatly appreciated.
    The range to copy will change every time I use it so I will just adjust the range in the VBA code until I become better at VBA, at which point in time I'd love to have VBA ask me to select a range and then it would run the rest of the code.

    Once I have this issue resolved, I still have three other task to automate with the newly pasted data.
    1.) One of the columns has negative numbers that need to be converted to positive numbers (so I'll need to select a range and multiply by -1)
    2.) One of the columns is a date and I'd like to sort everything that was pasted into this workbook from oldest to newest
    3.) Then I need to run a find/replace on text in one of the columns.

    If there are any resources or code example you can share to help with these other three issues I would love to learn.

    Thank You in advance for any and all assistance! I appreciate it!

    Ben
    Last edited by benyboy; 07-04-2020 at 02:43 PM. Reason: I found a line of unnecessary code

  2. #2
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA pasting range from other workbook to cell B2 instead of A2

    It would be easier to answer your question if you can upload a sample workbook. see Yellow banner above. And one of the moderators will ask that you place code tags around your code, [code ] before and [/code ] after, without the space. Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy/pasting from one workbook to another - Out of range error
    By isabelle.r in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-04-2017, 03:40 AM
  2. [SOLVED] Pasting an already copied two dimesional range from one workbook to another
    By chanauria in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-30-2016, 11:34 AM
  3. Copying a changing range from another workbook and pasting it after last column
    By badlydrunkboy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2014, 09:21 AM
  4. [SOLVED] Copying Active Cell-Row-Range to Other Workbook is pasting an image of copied range
    By jrtraylor in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-18-2013, 01:08 AM
  5. [SOLVED] Help pasting Range from one workbook to another
    By Matt3989 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-17-2013, 09:08 PM
  6. HELP with copying/pasting specific range into different workbook
    By wojizzle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2012, 08:29 AM
  7. Pasting Range from 1 Workbook into Multiple Workbooks
    By Leviathan in forum Excel General
    Replies: 2
    Last Post: 01-14-2011, 11:21 AM

Tags for this Thread

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