+ Reply to Thread
Results 1 to 8 of 8

Macro that refreshes/sort information

  1. #1
    Registered User
    Join Date
    01-25-2010
    Location
    Roanoke, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    53

    Macro that refreshes/sort information

    Attached is a simple soccer standing spreadsheet. What I want to accomplish is add a button on the first tab that reads "Refresh" (or anything else that it needs to be changed to), but what it needs to do is resort the standings, based on points (column F), with the highest number on the top.

    I have never done a macro, so any advice would be great!

    Thank you in advance!
    Attached Files Attached Files
    Last edited by SeanKosmann; 10-27-2010 at 03:46 PM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro that refreshes/sort information

    Have you tried using the macro recorder? It should give you the code that you require.

    Just start it recording and perform the action that you want and then stop it. You should then be able to attach the macro to a button from the Forms toolbar or an autoshape.

    If you need more help post back.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    01-25-2010
    Location
    Roanoke, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: Macro that refreshes/sort information

    Thanks Dom!

    I have never even heard of it... I'll look into it. One issue I ran into, even when I highlighted the area and did a special sort, picking column F, it wasn't doing it properly. I'll keep trying and see if I can't unbreak it!

    Thanks!

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro that refreshes/sort information

    Have a go. The code the recorder comes up with is often far from perfect but good at replicating tasks like sorting a table. If your sort isn't working in the first place it's probably another issue.

    I'll have a look at your sample.

    Dom

  5. #5
    Registered User
    Join Date
    01-25-2010
    Location
    Roanoke, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: Macro that refreshes/sort information

    The workbook is attached on the initial post, let me know what you see!

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro that refreshes/sort information

    You have the sheet ref in some formula ,e.g. =COUNTIF(Sheet2!E:E,Sheet1!A2), when it's referring to the same sheet the formula is on. This can create a kind of absolute reference I think which seems to cause problems.

    I've changed it and added some clean code to do the sorting which should do the trick.

    Dom
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-25-2010
    Location
    Roanoke, Virginia
    MS-Off Ver
    Excel 2007
    Posts
    53

    Re: Macro that refreshes/sort information

    So just taking out the "Sheet1" fixed it... man that's crazy... I would have spent hours thinking about that... thanks!

    This is exactly what I needed!

  8. #8
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro that refreshes/sort information

    If you wanted you could have the table sort each time the sheet is activated.

    Please Login or Register  to view this content.

    The code needs to go on the worksheet's code page to work. Right click on the sheet tab and select View Code. Paste the above onto the code page that appears.

    Dom

+ 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