+ Reply to Thread
Results 1 to 9 of 9

VBA to copy cell (with formula) to next row and then copy and paste values in cells above

  1. #1
    Registered User
    Join Date
    07-05-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    11

    VBA to copy cell (with formula) to next row and then copy and paste values in cells above

    Hi, i have a range of data in AG3:AG14, each month i copy the formula in the last row with data (i.e AG7) to the next row below i.e (AG8) and then copy and paste as values the cells above. How can i automate this with a macro?
    let me know if any further info is required. i.e below - i want to copy the formula (which gives me 138%) into the next available row and then copy and paste the above cell as a value. i do this once a month.

    Jan-13 159%
    Feb-13 120%
    Mar-13 113%
    Apr-13 107%
    May-13 138%
    Jun-13
    Jul-13
    Aug-13
    Sep-13
    Oct-13
    Nov-13
    Dec-13

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: VBA to copy cell (with formula) to next row and then copy and paste values in cells ab

    Try adapting this code. Put it into a standard module and use it as needed.
    Rows 1-2 are assumed to be header row
    Please Login or Register  to view this content.
    Always test code on a back up copy of the workbook.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    07-05-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA to copy cell (with formula) to next row and then copy and paste values in cells ab

    Hi, used your code but it didnt work. it didnt come up with an error message but nothing seems to have happened? Regards.

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: VBA to copy cell (with formula) to next row and then copy and paste values in cells ab

    It worked fine when tested. Maybe you should upload a sample workbook (fake data).

  5. #5
    Registered User
    Join Date
    07-05-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA to copy cell (with formula) to next row and then copy and paste values in cells ab

    Hi Palmetto. I created a test spreadsheet and tried it and it worked! thx so much.
    what i need to do now is amend the code so that if i have two ranges in the same colmun to perform the same function for both ranges - using one macro.

    i have attached the file below. how would the code be written? ican then try and manipulate for other columnd and worksheets too.
    Attached Files Attached Files

  6. #6
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: VBA to copy cell (with formula) to next row and then copy and paste values in cells ab

    Works with your sample workbook.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-05-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA to copy cell (with formula) to next row and then copy and paste values in cells ab

    WOW! You are a genius. Thanks for this Palmetto. I have started to add to this code so that if I have other ranges of data in the same worksheet I can copy the last row and it worked great.

    Hopefully my final question is how do I repeat a similar step but in a different worksheet (in the same macro)? I would like to copy the FORMULA in the last row of columns K to N of the worksheet "Sales Ops Data" into the next row below and then make the row above as values...I tried to do it in the same macro (as a test on column L) but it doesn't work

    Also once i have completed this last step in "Sales Ops Data" I want to make the row above white (i.e May) and the row below (i.e June) light Green - (to show this is the current month) if this last step is too hard then don't worry.

    Thx!
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-05-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA to copy cell (with formula) to next row and then copy and paste values in cells ab

    Hi...is this achieveable in VBA? Any advice would be appreciated. I am half way there with the code...

  9. #9
    Registered User
    Join Date
    07-05-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: VBA to copy cell (with formula) to next row and then copy and paste values in cells ab

    I have managed to work out how to do this for another sheet in one macro. The last part is to do with the formatting of the cells, i.e:

    highlight the current month row green and make last month's row white...any tips?

+ 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