+ Reply to Thread
Results 1 to 9 of 9

VBA to insert data in formula, then copy paste the result

  1. #1
    Registered User
    Join Date
    09-19-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    3

    VBA to insert data in formula, then copy paste the result

    Hey everyone!

    I have tried to make a macro to use at work. We use some very complicated formulas that get data from all over the sheets, I use these in combination with raw data which I have to input manually. Sometimes there's 20 entries, and sometimes there's 200. What I would like the macro to do:

    Copy the first row of my data column on sheet 2, paste it in a specific cell in sheet 1 (A2 in my example file).
    This will add the value in my 'very complicated' formula which gives a result in cell C3.
    I wish to copy this value and paste it in the B column on sheet 2. I use paste special --> value for this otherwise excel will get angry.
    After this I want to copy the second row of my data column on sheet 2, paste it back in cell A2 in sheet 1.
    This will yield a new result from the very complicated formula, this result will need to be moved back to sheet 2.
    and so on and so on.

    What I have tried:
    I have tried to find a simple solution but I think my problem is too specific. I have tried to make a working macro using the excel record macro function (I am really bad with coding stuff). This macro does work, however I would like to edit it so that it will keep going until there is no more data. When I input 20 rows it will give me 20 results, when I input 200 rows it will give me 200 results.

    Perhaps I should use the record macro to do 200 lines but I am sure there is an easier way to do this. I hope you guys can help me out!

    I have attached an example file with 2 macros, macro 1 is just a shorter version that moves one row of data, macro 2 moves three.

    - Voggy
    Attached Files Attached Files

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to insert data in formula, then copy paste the result

    Is this right?

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    09-19-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    3

    Re: VBA to insert data in formula, then copy paste the result

    That works! But your macro doesn't use the formula on the sheet at all? You write your own formula in the macro...

    Is there a way you can use that loop with the copy and pastevalue?
    Last edited by Voggy; 09-20-2017 at 05:31 AM.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: VBA to insert data in formula, then copy paste the result

    Hi Voggy

    As per your request????
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 09-20-2017 at 07:23 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  5. #5
    Registered User
    Join Date
    09-19-2017
    Location
    London
    MS-Off Ver
    2013
    Posts
    3

    Re: VBA to insert data in formula, then copy paste the result

    Yes Sintek. That is exactly what I was looking for! Thanks a lot!

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: VBA to insert data in formula, then copy paste the result

    Pleasure. Glad I could contribute. Thanks for rep +

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to insert data in formula, then copy paste the result

    Hi Voggy,

    Thanks for the rep!

    The macro only posts values as it is and should be, if anything, a little quicker than a copy paste value

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,176

    Re: VBA to insert data in formula, then copy paste the result

    I'm with you on this one xladept...Your version much more expedient.

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA to insert data in formula, then copy paste the result

    Thanks sintek!

+ 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 paste data into result sheet
    By globalsourcing in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-22-2016, 06:08 PM
  2. Copy & paste input data to sheet, copy result back out
    By stuartsjg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-30-2015, 05:25 PM
  3. copy paste result from formula
    By Burt_100 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2015, 04:23 AM
  4. copy/paste vlookup result NOT formula
    By cbrownbosgus in forum Excel General
    Replies: 2
    Last Post: 02-22-2011, 10:11 PM
  5. Copy paste data, insert rows, insert data and change . to -
    By xWiZardx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2010, 01:44 AM
  6. Replies: 1
    Last Post: 05-20-2009, 08:15 AM
  7. [SOLVED] Copy Paste of Formula Produces Incorrect Result
    By JLa in forum Excel General
    Replies: 1
    Last Post: 05-17-2005, 02:06 PM

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