+ Reply to Thread
Results 1 to 11 of 11

Copy contents of cell before macro clears it

  1. #1
    Registered User
    Join Date
    07-03-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    6

    Copy contents of cell before macro clears it

    Hey All, first of all. I have learned so much from everyone here and have never actually posted any questions before.. because I haven't needed to. But, today I'm stumped.

    I am creating a sheet that will be used as a multiplayer score sheet for playing darts.
    I have created a macro clears the "Scores" column by clicking a button after each game ends. During the scoring of each game, I have countif Eg:
    Please Login or Register  to view this content.
    formulas that are picking out the scores over 99, over 139 and over 179. as well as calculating averages during the game. eg:
    Please Login or Register  to view this content.
    What I can't figure out is how to save that counted data after I click the "reset scores" button. So I can keep a running count of how many 100+'s, and so on, or an average over a match.
    Here is the Macro script I am running (I did not write this, I found it by searching ) - I should add, this script works great. I have a button at the top of each players section to clear their scores for a new game.

    Please Login or Register  to view this content.
    I figure an addition to this macro that copies the cell contents to another worksheet called totals and adds them up would be the best option, but again, I'm not the expert here

    Any thoughts? I have attached the file if anyone is interested in using for themselves or to help figure this out

    And thanks again for any help any of you can offer!!
    Attached Files Attached Files
    Last edited by tm875430; 12-14-2017 at 09:28 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Copy contents of cell before macro clears it

    What data would you want copied and where exactly would the data be copied to on the Totals sheet?
    If posting code please use code tags, see here.

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

    Re: Copy contents of cell before macro clears it

    Try this:

    Please Login or Register  to view this content.
    I figured you'd want to erase the totals eventually - just put the red code in each "P" routine
    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

  4. #4
    Registered User
    Join Date
    07-03-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Copy contents of cell before macro clears it

    Quote Originally Posted by Norie View Post
    What data would you want copied and where exactly would the data be copied to on the Totals sheet?
    In an ideal situation, I would like to have the totals remain in the same place on the Scores sheet. But I thought that may be more difficult than sending them to a new sheet altogether.
    The data I would like to copy would be 100+, 140+, 180's, Legs, Leg Avg.

    Thanks!

  5. #5
    Registered User
    Join Date
    07-03-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Copy contents of cell before macro clears it

    Quote Originally Posted by xladept View Post
    Try this:

    Please Login or Register  to view this content.
    I figured you'd want to erase the totals eventually - just put the red code in each "P" routine
    Thanks for this, it seems to almost work
    I do get the data copied over to the Totals sheet however the totals are all still 0.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: Copy contents of cell before macro clears it

    Post #1 does not comply with Rule #3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, 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

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  7. #7
    Registered User
    Join Date
    07-03-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Copy contents of cell before macro clears it

    my apologies, OP has been corrected.

    Thanks for pointing that out to me.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: Copy contents of cell before macro clears it

    Thanks.

  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: Copy contents of cell before macro clears it

    Replace the SaveTotals routine code with:

    Please Login or Register  to view this content.
    Last edited by xladept; 12-14-2017 at 01:11 PM.

  10. #10
    Registered User
    Join Date
    07-03-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Copy contents of cell before macro clears it

    Quote Originally Posted by xladept View Post
    Replace the SaveTotals routine code with:

    Please Login or Register  to view this content.
    So, i managed to figure this out by doing it the long way-ish, To copy the values (not the formulas) from the Scores sheet to the Totals sheet, and add them together, I used this:
    Please Login or Register  to view this content.
    Then, I created another macro to call both Macro's to Copy_Values and ClearContents.

    Still Can't figure out the Averages though. I though of maybe copying the Leg_Avg from the Scores sheet to a hidden column on the Totals sheet, then a formula that sums the values in said hidden column... appending each value to the end of the hidden column every time the "reset scores" button is clicked; then dividing that sum by the number of rows used to give you an average of your combined averages. Not a true way to calculate that figure but it's the best I can think of right now.

  11. #11
    Registered User
    Join Date
    07-03-2013
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Copy contents of cell before macro clears it

    Updated Sheet Attached
    Attached Files Attached Files

+ 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. Macro that clears cell contents on criteria
    By traderdays123 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-23-2017, 09:05 AM
  2. [SOLVED] VBA Code that Clears contents of specific column in row
    By Jamidd1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2016, 07:49 AM
  3. macro to copy cell contents then remove substring of contents in new cell - Help
    By three_jeeps in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-25-2015, 01:19 AM
  4. Macro Problem: Copy contents of cell; search for contents in another workbook
    By jfishstik in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-04-2014, 12:11 PM
  5. [SOLVED] Macro which clears contents below X text until it encounters Y text
    By SF1eagles in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-04-2014, 04:16 PM
  6. Macro that clears contents of all cells of certain colour (colour 35) in all sheets
    By Hanskubansku in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-25-2012, 07:33 AM
  7. Macro clears contents and my formula references
    By moike in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-19-2006, 01:04 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