Ask Experts Questions for FREE Help !
Ask
    dannac's Avatar
    dannac Posts: 267, Reputation: 9
    Full Member
     
    #1

    Sep 21, 2013, 02:41 AM
    Looking for VBA to sort workers


    Workbook has 2 sheets.
    Sheet 1 has all the data.
    Workers in col A and the amount of rows changes.
    Categories are listed in B1:X1.

    Sheet 2 has a validation dropdown in cell A1.
    It references a named range from sheet 1 (B1:X1)

    Workers have info under different categories.

    From sheet 2 I would like to choose a name from the dropdown in A1.
    The macro would search categories on Sheet 1 that match dropdown.

    Then copy the worker's entire row... only if they have info under that category.

    Row would be copied to sheet 2 starting in cell A3.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #2

    Sep 21, 2013, 07:21 AM
    Excel has a macro recorder. You can try recording the steps you take, then view the generated code to make it more dynamic.
    dannac's Avatar
    dannac Posts: 267, Reputation: 9
    Full Member
     
    #3

    Sep 21, 2013, 09:25 AM
    I have used macro recorder for simple things.

    I do not believe this can even be started, much less accomplished with the macro recorder.

    Not a simple task.

    Thanks for your reply.
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #4

    Sep 21, 2013, 10:07 AM
    You should be able to record a macro to copy a range from one area to another. Then look at the selection process.

    At least it will be a start.
    dannac's Avatar
    dannac Posts: 267, Reputation: 9
    Full Member
     
    #5

    Sep 24, 2013, 12:32 PM
    Yes I can record a copy operation with a macro.

    I do not see how to record a "find" or "search" operation with a macro.

    I'm hoping the "Software Expert" can help.
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #6

    Sep 26, 2013, 01:37 AM
    Your question first states sheet2 A1 would have a drop down comprised of B1:X1 from SHeet1, that's the categories.

    Then you state you'd like to choose a worker name in A1. You would need a second cell, perhaps B1 to select the worker name?

    Else your requirements are unclear. Please restate them step by step.

    Sheet1
    1) Names in column A
    2) Categories in Row 1

    Sheet2
    3) A1 has a drop down with categories from sheet1
    4) B1 has a drop down with names from sheet1

    Event
    5) When a category is A1 AND a name in B1 are selected, the following happens:

    - - ?
    - - ?
    - - ?

    Please be very specific. Thanks.
    dannac's Avatar
    dannac Posts: 267, Reputation: 9
    Full Member
     
    #7

    Sep 26, 2013, 04:15 AM
    Morning JB... you up early.

    I do not believe I stated I would choose a worker name.

    In fact, I should not have mentioned anything about the worker names as it does not look for worker name.

    It would search category only.

    It finds the category and copies the entire row of "non-blank" cells under that category to Sheet 2 starting at A3.

    Thanks for replying
    dannac's Avatar
    dannac Posts: 267, Reputation: 9
    Full Member
     
    #8

    Sep 26, 2013, 06:48 AM


    If I would search for Cat3 from the dropdown on Sheet 2

    It would return row 3, 6, and 8 to Sheet 2 starting at A3.
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #9

    Sep 26, 2013, 11:39 PM
    Like so, see attached.
    Attached Files
  1. File Type: xls DynamicLookup.xls (39.0 KB, 123 views)
  2. dannac's Avatar
    dannac Posts: 267, Reputation: 9
    Full Member
     
    #10

    Sep 27, 2013, 02:07 AM
    Exactly... thanks very much JB.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search


Check out some similar questions!

VBA If Statement [ 4 Answers ]

Ok. Here's my problem. I have a spreadsheet that I use which filters on 6 different filter criteria and copies the result set of each filter criteria to a separate worksheet. However, on occasion there are no results found for a given criteria. What I want to do is when no results are found...

Can VBA do this for me? [ 7 Answers ]

Refer attachment; For sheet "SPPA" cell "D18" value to be recorded on sheet "HO plan" cell "T7", and this is where it gets nasty, as the date rolls over on the "SPPA" sheet cell "F1", so must the macro record the new value in the next cell for sheet "HO plan", ie: If "SPPA" sheet cell "F1"...

Can this be done using VBA? [ 5 Answers ]

Ok - I have a spreadsheet that is exported from an application I use at work. It formats the data in a manner that makes it really difficult to manipulate but I think I've worked out a solution that gets me what I need; only it is very tedious. The data starts in row 16 of the sheet. There is...

Excel vba [ 1 Answers ]

I am working on an excel sheet vba, I wanted to un hide the cells with a click on one cell above it without using the command button

Sort a Column & sum the range with same value during the sort [ 2 Answers ]

Hi, I'm trying to sort a data table by Grades & then sum the totals of the cell with same Grade. The table consists of this headers: Date, DD#, Grade, Bags so what I'm trying to do is to come up with a formula that can sort by Grade & then add the total Bags against that particular Grade and...


View more questions Search