+ Reply to Thread
Results 1 to 9 of 9

vba macro to copy paste various various and return the result in a table

  1. #1
    Forum Contributor
    Join Date
    02-13-2013
    Location
    Columbia, SC
    MS-Off Ver
    Excel 2010
    Posts
    217

    vba macro to copy paste various various and return the result in a table

    I have a column C. I want to find the last value in column C and replace it with various values. The values I want to replace it with are in a table.
    The first value is in cell S2. So I want to copy the value in cell S2 and paste it in the last cell in column C (so replacing what was already there).

    Then I want to find the value in the last cell in column I, and paste that value to T2.

    Then repeat. So take value in S3, put it in last cell in column C. Find the new value in the last cell in column I, and paste that to cell T3.

    I want to do this for all cells in column S.

    Can this be done with VBA? It would save me a ton of time, as my hand is becoming numb doing this constantly manually.

    When it pastes the result, it needs to just paste the number, not the formatting or anything like that.

    So basically to sum up, I have a table in columns S and T. I want to take each value in column S (separately), paste that in the last cell in column C, find the returned value in the last cell in column I, and paste that into the corresponding spot in the table (T2, T3, T4, etc.)
    Attached Files Attached Files
    Last edited by bjcowen9000; 09-02-2020 at 11:12 AM.

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

    Re: vba macro to copy paste various various and return the result in a table

    Yes it can be done. Please provide an example file as per the yellow banner above so we can assist you further

  3. #3
    Forum Contributor
    Join Date
    02-13-2013
    Location
    Columbia, SC
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: vba macro to copy paste various various and return the result in a table

    I just added the example workbook. I put the first few answers in column T to check to make sure it is right.

    So the idea is:

    1) Take S2 value, paste in last cell in column C
    2) Copy last cell in column I to T2
    3) Take S3 value, paste in last cell in column C (overwriting S2 value)
    4) Paste new last cell in column I to T3.

    I do not want to make the length of column C any longer. I just want to replace it with each new value, find the corresponding result in column I, and copy the answer to column T.

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

    Re: vba macro to copy paste various various and return the result in a table

    Here you go :

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    02-13-2013
    Location
    Columbia, SC
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: vba macro to copy paste various various and return the result in a table

    Thanks! It looks mostly good! Is there any way to have it stop at the last cell in S column? It keeps going past it on mine and I assume it just is pasting "0" over and over again as it goes past the last value in S

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

    Re: vba macro to copy paste various various and return the result in a table

    The code is stopping at the last 'active cell' in column S. Select all the cells below your last S value and delete those cells. The system is probably seeing these cells as 'alive with data, although blank'

  7. #7
    Forum Contributor
    Join Date
    02-13-2013
    Location
    Columbia, SC
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: vba macro to copy paste various various and return the result in a table

    I guess I still do not understand why this works. You are explicitly picking the last cell in column C, but I need to just find what the last cell is and pick that. This would not be useful across many workbooks with varying column lengths. Is there any way to generalize it so it just finds the last active cell in column C?

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

    Re: vba macro to copy paste various various and return the result in a table

    Please Login or Register  to view this content.

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

    Re: vba macro to copy paste various various and return the result in a table

    If that takes care of your original question, please select*Thread Tools*from the menu link above and mark this thread as SOLVED.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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] Macro to Copy and Paste based on VLOOKUP result
    By promvonp in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-05-2019, 02:54 AM
  2. VBA Macro to Copy and Paste in a table
    By Ransick in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-20-2018, 11:01 AM
  3. [SOLVED] Macro to apply a new number and then copy the result to a new table
    By rongil20 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-07-2015, 09:27 AM
  4. [SOLVED] Macro to copy/paste information to a table
    By jono7gold in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-14-2014, 08:05 AM
  5. Macro to copy/paste values based on the result of a cell
    By Phily915 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-12-2014, 07:10 PM
  6. Macro to Copy Pivot Table and Paste a Regular Data Table in the Same Position
    By webfeet2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-01-2013, 06:34 AM
  7. Macro to copy a table and paste in another table (based on certain conditions)
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-22-2013, 01:14 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