+ Reply to Thread
Results 1 to 3 of 3

VBA code to copy and paste data from one sheet to another, variable locations

  1. #1
    Registered User
    Join Date
    12-16-2019
    Location
    Colchester,England
    MS-Off Ver
    2013
    Posts
    18

    VBA code to copy and paste data from one sheet to another, variable locations

    In summary, I am trying to achieve the following:
    -I have a workbook containing two sheets (Sheet1 & Sheet2) Sheet1 will contain raw data a number label in columnA and the data value in columnB, sheet2 will contain formula at various locations
    -I would like to be able to enter two variables in sheet2, in cells A1, and B1. When the code is ran I would like excel to search sheet1 columnA for the value entered in sheet2 A1, copy the adjacent data value, then search sheet2 columnC for the value in sheet2 B1 and paste to the corresponding adjacent cell in columnD.
    I have the code below which will complete the first two parts of the procedure.

    Please Login or Register  to view this content.
    This searches columnA sheet1 for the value in sheet2 A1 and copies to a set location (D3).

    What I need is for the paste location to be either D3 or D6, depending on if the value entered in B1= the value in C3 or C6.

    Does anyone know how to change the paste location , based on the concept described above?

    Note. I have simplified this as much as possible for the purposes of getting code to work, in practice I will need to adapt it to copy several batches of rows at a time to several possible locations.

    Apologies I cannot post the spreadsheet; the version I am using has a proprietary VBA installed (that is nothing to do with this particular calculation) which I am not allowed to post
    Last edited by PeterYoung700; 12-16-2019 at 09:26 AM.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: VBA code to copy and paste data from one sheet to another, variable locations

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    I did it for you this time. Please read forum rules. Thanks

  3. #3
    Registered User
    Join Date
    12-16-2019
    Location
    Colchester,England
    MS-Off Ver
    2013
    Posts
    18

    Re: VBA code to copy and paste data from one sheet to another, variable locations

    Thanks for the pointers; no problem I will make sure I do this going forward.

+ 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. [SOLVED] VB Code to filter data and copy paste in another sheet
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-06-2020, 11:43 PM
  2. [SOLVED] Copy & Paste Variable data length into summary sheet after last used row
    By Roshan.Shakya in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-05-2019, 11:53 AM
  3. [SOLVED] Copy & Paste Variable data length into summary sheet after last used row
    By spyac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-14-2018, 11:31 AM
  4. VBA code for copy visible data and paste in another sheet
    By bolla mani in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2015, 05:19 AM
  5. Replies: 2
    Last Post: 01-22-2014, 05:36 PM
  6. VBA code to put a pivot and copy paste the data on a other sheet
    By aravindkm in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-28-2013, 12:07 PM
  7. Replies: 1
    Last Post: 03-28-2013, 02:49 PM

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