+ Reply to Thread
Results 1 to 3 of 3

VBA problems with finding max values en copying names to a different worksheet.

  1. #1
    Registered User
    Join Date
    05-30-2019
    Location
    Netherlands
    MS-Off Ver
    Excel 2012
    Posts
    1

    Talking VBA problems with finding max values en copying names to a different worksheet.

    Hi guys,

    My name is Tim and I am new to this Forum.
    I experience a lot of trouble while designing my first code in Excel VBA. The problem is as following: in column B(worksheet 1), I inserted the names of some students. in column C, I inserted the marks of the corresponding students (see table 1).

    In worksheet 2 table 2, I want cells A1:A3 to display the names of the 3 best students. After watching a lot of Youtube-tutorials, I still did not manage tot figure out how to do it. Is there anyone who could help me designing this code in VBA?

    Thanks in advance!
    -------------------------------------------------------

    Table 1 worksheet 1:

    Student Mark
    Alex 9,5
    Sophie 7
    Nick 8
    Paul 4
    Helena 9
    jan 6

    table 2 worksheet 2:
    Best students
    ?
    ?
    ?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA problems with finding max values en copying names to a different worksheet.

    Hello TimExcel123,

    Welcome to the forum!

    This will sort the data in table 1 in descending order using the "Marks" column and then copy the top 3 names to table 2 "A1:A3" on Sheet2. You may need to change the worksheet names in the macro code if your worksheet names aren't the same.

    Please Login or Register  to view this content.
    This code needs to be a Standard VBA Module. You can then call this macro manually using the ALT+F8 keys to open the Macro Dialog or call the macro using a button on a worksheet or from other VBA code.
    1. Copy the macro with Ctrl+C.
    2. Open the workbook and use Alt+F11 to open the VB Editor.
    3. Use ALT+I to display the Insert Menu.
    4. Press the M key to add a new Module.
    5. Paste the macro into the Module with Ctrl+V.
    6. Save the macro using Ctrl+S
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,143

    Re: VBA problems with finding max values en copying names to a different worksheet.

    Quote Originally Posted by TimExcel123 View Post
    ... designing this code in VBA ...
    If you don't insist on vba, then you can achieve it with a formula, e.g. in 'A1' (Sheet2) and copy down:
    Please Login or Register  to view this content.

+ 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. Replies: 1
    Last Post: 08-19-2013, 08:56 AM
  2. Problems copying a worksheet
    By Ascopeland in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-29-2012, 07:16 PM
  3. [SOLVED] Macro for Finding Sheet Names, then Copying/Pasting Values
    By Joel.Nemec in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-09-2012, 01:28 PM
  4. [SOLVED] finding the names of the values within a formula
    By Sarangsood in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-09-2011, 11:16 AM
  5. [SOLVED] Finding/removing duplicate names in a worksheet
    By Dave in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-17-2006, 03:10 PM
  6. [SOLVED] Problems with a finding macro and copying a range of cells
    By Agasnine in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-20-2005, 03:25 PM
  7. [SOLVED] Finding all hyperlinks in row a, copying to new worksheet
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-24-2005, 09:05 AM
  8. Replies: 4
    Last Post: 05-13-2005, 01:06 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