Consulting

Results 1 to 5 of 5

Thread: Lookup and insert rows

  1. #1
    VBAX Newbie
    Joined
    Oct 2015
    Posts
    5
    Location

    Lookup and insert rows

    Hi,

    I am building an estimating tool.
    I have a drop down box that can select multiple values,(jobs). let’s say one of those is “build a shed”
    “Build a shed” as 10 associated tasks allocated to it, and other jobs have a varying number of tasks

    Once the drop down selection has been made I want a macro that will count the number of tasks against the job and then add those number of rows underneath that drop down then I want to auto populate with the tasks details involved with “Build a shed”, or it can copy the selection from the job and insert direct into the sheet.


    Jobs Tasks Duration (Hrs)

    Build a Shed A 8
    Build a Shed B 7
    Build a Shed C 6
    Build a Shed D 5
    Build a Shed E 4
    Build a Shed F 3
    Build a Shed G 2
    Erect a Fence A 2
    Erect a Fence B 6
    Erect a Fence C 8
    Erect a Fence D 8
    Erect a Fence E 2


    If there is an easier way, I’m all up for easier.
    Any help would be greatly appreciated.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    How much VBA Coding experience do you have?
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Newbie
    Joined
    Oct 2015
    Posts
    5
    Location
    Hi SamT
    Low to medium experience and it has been a few years since I have done any VBA.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    A few years ago I was working on an estimator similar to your idea. My idea was to Use a UserForm for initial input with the first ComboBox (AKA Multi-column dropdown. Example: cmboJobs) to access the list in Column A, of the attachment. The code would then Find across Row one for the Item selected (Example: "Foundation") in cmboJobs and assign the Range associated with "T3" to the next ComboBox .
    cmboTasks.RowList = Rows(1).Find(cmboJobs.Value).CurrentRegion
    In the Next ComboBox (cmboTasks) when the User selected an item (Example: "Trenching") the code would Find down the same column that "T3" was found in for "TTrn" and assigns the found CurrentReqion to the next ComboBox.

    The trick is that VBA UserForm ComboBoxes can have multiple Columns and some can be hidden from the User, but all can be used by Code. The first Column will be the Value of the ComboBox, but can be hidden from the User. I was going to use the third column for subsidiary WorkSheets when present.

    Note that I am not talking about Form or Control ToolBox controls as found in the Excel Menu. I use the controls found in VBA when you Insert a UserForm in the Project Explorer Pane.
    Attached Files Attached Files
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Newbie
    Joined
    Oct 2015
    Posts
    5
    Location
    SamT
    Thank you. Just need to get my head around this, but it sounds good.

    Cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •