Link to home
Start Free TrialLog in
Avatar of Sharmal Butler
Sharmal ButlerFlag for United States of America

asked on

Preselect listbox items and map to another listbox

Expert,

I need  a script to add to a user form that maps list of items when one of the items  from the list is selected.  it will automatically map to the associated item. For example, If I select with a check box  from License Type - Customer Community, it will automatically pull into the form from License Type 2 - Community and so on.

For Example:

License Type  List                            License Type 2 List
customer Community                   Community
Partner Community                       Community
Additional 10 Object                      Community Add-On
Force.com, Unlimited Ed               Force.com
Email Messages                              Marketing Cloud

I am not that familiar with VBA so would need to know where to place the script..

Current user form Code is below:

Option Explicit
Dim rData As Range, Cl As Range
Dim oWs As Worksheet
Dim lRw As Long, T As Long, P As Long, lPos As Long
Dim iX As Integer, iCol As Integer
Dim bInit As Boolean, bEdit As Boolean


Private Sub cboFind_Change()
    Dim cUnique As Collection
    Dim vNum As Variant

    Me.cmdSearch.Enabled = Me.cboFind.ListIndex > -1
    iCol = Choose(Me.cboFind.ListIndex + 1, 4, 2, 5, 16)

    Set cUnique = New Collection

    On Error Resume Next
    For Each Cl In rData.Columns(iCol).Cells
        cUnique.Add Cl.Value, CStr(Cl.Value)
    Next Cl
    On Error GoTo 0

    For Each vNum In cUnique
        Me.cboCriteria.AddItem vNum
    Next vNum
End Sub



Private Sub chkNew_Click()

    If chkNew Then
        lPos = Me.lbxData.ListIndex
        ClearAll Me
        Me.editstudent2.Value = Application.WorksheetFunction.Max(rData.Columns(2)) + 1
    Else: Me.lbxData.ListIndex = lPos
    End If
    
    Me.cmdAdd.Enabled = chkNew
    bEdit = chkNew
End Sub

Private Sub cmdAdd_Click()

    WriteToSheet
End Sub

Private Sub cmdSearch_Click()
    Dim TempSht As Worksheet, rTemp As Range
    Dim lIndex As Long, lTot As Long

'    If Not oWs.Range("A4").AutoFilter Then oWs.Range("A4").AutoFilter

    If oWs.FilterMode Then oWs.ShowAllData

    Set TempSht = Worksheets.Add
    rData.AutoFilter Field:=iCol, Criteria1:=Me.cboCriteria.Value
    rData.Copy
    With TempSht

        .Cells(1).PasteSpecial xlAll
        Me.lbxData.Clear
        Set rTemp = .Range(.Cells(2, 1), .Cells(.Rows.Count, 15).End(xlUp))
        Set rTemp = rTemp.Resize(rTemp.Rows.Count + 2, rTemp.Columns.Count)
        rTemp.Columns.AutoFit
        ColumnWidths rTemp
        With Me.lbxData
            .List = rTemp.Value
            .AddItem
            .List(.ListCount - 2, 4) = "TOTAL: " & Me.cboFind.Value & "  " & Me.cboCriteria.Value
            For lIndex = 0 To .ListCount - 1
                If IsNumeric(.List(lIndex, 12)) Then
                    lTot = lTot + .List(lIndex, 12)
                End If
            Next
            .List(.ListCount - 2, 12) = "Qty: " & lTot

            For lIndex = 0 To .ListCount - 1
                If IsNumeric(.List(lIndex, 13)) Then
                    lTot = lTot + .List(lIndex, 13)
                End If
            Next
            .List(.ListCount - 2, 13) = lTot
            .List(.ListCount - 2, 13) = FormatCurrency(.List(.ListCount - 2, 13))
            lTot = 0
        End With
        Application.DisplayAlerts = False
        TempSht.Delete
        Application.DisplayAlerts = True
        oWs.ShowAllData
    End With
End Sub


Private Sub editstudent1_Enter()
    If Not bInit Then Exit Sub
    g_bForm = True
    frmCalendar.Show_Cal
    Me.editstudent1.Value = g_sDate
End Sub

Private Sub editstudent10_Enter()
    If Not bInit Then Exit Sub
    g_bForm = True
    frmCalendar.Show_Cal
    Me.editstudent10.Value = g_sDate
End Sub

Private Sub editstudent9_Enter()
    If Not bInit Then Exit Sub
    g_bForm = True
    frmCalendar.Show_Cal
    Me.editstudent9.Value = g_sDate
End Sub

Private Sub imgDone_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    With Me.fraSearch
        .Top = T
        .Left = P
        .Visible = False
    End With

    With Me.lbxData
        .Clear
        .ColumnCount = 19
        .List = rData.Offset(1).Resize(rData.Rows.Count - 1, _
                                       19).Value
        .ListIndex = 0
        lRw = .ListIndex
    End With
End Sub



Private Sub imgSearch_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    With Me.fraSearch
        T = .Top
        P = .Left
        .Top = Me.imgSearch.Top
        .Left = Me.cmdUpdate.Left
        .Visible = True
    End With
End Sub


Private Sub lblViewAll_Click()

    With Me.lblViewAll
        If .Caption = "View all columns" Then
            .Caption = "Compact view"
            With Me
                .lbxData.Width = Evaluate(Replace(Replace(.lbxData.ColumnWidths, ";", "+"), " pt", "")) + 10
                .lbxData.Height = .lbxData.Height * 1.25
                .lbxHeader.Width = .lbxData.Width
                .Height = Application.Height
                .Width = Application.Width
                .Left = Application.Left
                .Top = Application.Top
            End With
        Else:
            Unload Me
            frmeditrecord.Show
        End If
    End With

End Sub

Private Sub lbxData_Click()
    lRw = Me.lbxData.ListIndex
    LoadBoxes
End Sub



Private Sub UserForm_Initialize()

    Set oWs = Sheet1
    With oWs
        Set rData = .Range(.Cells(3, 1), .Cells(.Rows.Count, 26).End(xlUp))
    End With
    
    editstudent1.SetFocus

    With Me
        .lblCap.Caption = "Add or Edit Records"
        .cboFind.List = Array("Quote #", "Ref#", "License Type", "License Type 2")
        .cmdSearch.Enabled = .cboFind.ListIndex > -1
        .Width = 810
        .Height = 560
    End With

    For iX = 1 To 13
        Me("lbl" & iX).Caption = rData.Cells(1, iX).Value
    Next iX

    For iX = 14 To 17
        Me("lbl" & iX).Caption = rData.Cells(1, iX + 2).Value
    Next iX

    ColumnWidths rData
    Me.lbxData.ListIndex = Me.lbxData.ListCount - 1
    LoadBoxes
    bInit = True
End Sub

Sub ColumnWidths(r As Range)
    Dim CW As String
    With Me.lbxData
        .ColumnCount = 19
        .List = rData.Offset(1).Resize(rData.Rows.Count - 1, _
                                       19).Value
        .ListIndex = 0
        CW = ""
        ''///match ColumnWidths to Columns
        For iX = 1 To .ColumnCount
            CW = CW & rData.Columns(iX).Width & ";"
        Next iX
        .ColumnWidths = CW

    End With

    With Me.lbxHeader
        .ColumnCount = Me.lbxData.ColumnCount
        .List = rData.Rows(1).Value
        .ColumnWidths = CW
    End With
End Sub
Private Sub cmdClr_Click()
    ClearAll Me
End Sub

Private Sub cmdUpdate_Click()
    WriteToSheet
End Sub


Private Sub cmdExit_Click()
    Unload Me
End Sub
Sub WriteToSheet()

    If bEdit = True Then
        lRw = rData.Rows.Count + 1
    Else
        lRw = Me.lbxData.ListIndex + 2
    End If

    For iX = 1 To 13
        rData.Cells(lRw, iX).Value = Me("editstudent" & iX).Value
    Next iX

    For iX = 16 To 19
        rData.Cells(lRw, iX).Value = Me("editstudent" & iX - 2).Value
    Next iX

    If bEdit = True Then
        rData.Cells(lRw - 1, "N").Resize(, 2).Copy rData.Cells(lRw, "N")
        rData.Cells(lRw - 1, "Q").Copy rData.Cells(lRw, "Q")
        rData.Cells(lRw - 1, "T").Resize(, 9).Copy rData.Cells(lRw, "T")
    End If
    
    rData.Columns.AutoFit
    ColumnWidths rData

    Me.chkNew.Value = False
    
End Sub
Sub LoadBoxes()
    Me.lblMsg.Caption = "Displaying record #" & lRw + 1 & " of " & rData.Rows.Count - 1 & " records"

    For iX = 0 To 12
        Me("editstudent" & iX + 1).Value = Me.lbxData.List(lRw, iX)
        Me("editstudent" & iX + 1).Font.Size = 10
    Next iX

    For iX = 15 To 18
        Me("editstudent" & iX - 1).Value = Me.lbxData.List(lRw, iX)
        Me("editstudent" & iX - 1).Font.Size = 10
    Next iX


End Sub

Open in new window

Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Can you supply a sample workbook?
Avatar of Sharmal Butler

ASKER

attached is the sample workbook.
29136966e-v1.07ab.xlsm
Okay are you saying that when you click the field to the right of "License Type" that you want to see a list of the unique license types, and when you click one of them that the field to the right of "License Type 2" will be filled with a list of the unique license type 2's associated with the selected license type?
There can be many unique license types  but only one unique  license type 2 associated to it.

Customer community and partner community  would be associated  to community.

If I select  from license type customer community.  The drop list should only show community  to be selected from licensed type 2

Even better if it can automatically pull in the associated license type2 when selected.  I plan to have a separate sheet tab with all the current license types and associated license type 2. Also ther maybe news added to this list.  I did not add this into the sample workbook
Avatar of Norie
Norie

I'm a bit confused, as far as I can see there's only one listbox on your form.
Once a unique license type is chosen, let's say "Marketing Cloud, Enterprise Edition", please tell me what should show for License Type 2, and how that is determined with row number examples.
Also I'm a little confused because you mention a "License Type 2 List", but now you seem to be saying that there should be only one.
Noire,

I do not have a list box created yet.  This what I need help with. I apologize for any confusion
What about my last two questions?
Martin,

I am trying to figure out a way to explain what I want.  I am struggling a bit.  

Both License Type and License Type 2 will be lists on a separate tab/sheet.

Because the license type names can vary slightly making them unique  it was difficult to perform analysis or produce pivot tables.  Therefore, we narrowed down the names under the license type 2 to make easier for us to identify these licenses. So, as the example for "Marketing Cloud, Enterprise Edition",  "Marketing Cloud, Enterprise unlimited Edition", and "Marketing Cloud, Enterprise unlimited Edition II"  are the same licenses. But due to the inconsistency of how the quotes are written we had to come up with a way to identify them as the same license type. Therefore, we decided to called them under the license type 2  "Marketing Cloud-Add on".

So, in the user form I am looking for a a drop down of all the license Type.  If i selected any one of the license type then it should automatically fill in the license type 2 to field that it is associated to

I added a updated attachment that includes an abbreviated listing of the license type and license type 2 names.  This list will expand.

License Type                                                                          License Type2
1. Marketing Cloud, Enterprise Edition                          Marketing Cloud Add-on
2. Marketing Cloud, Enterprise unlimited Edition          Marketing Cloud Add-on
3. Marketing Cloud, Enterprise unlimited Edition II   Marketing Cloud Add-on
4. Customer Community                                                  Community
5. Partner Community                                                  Community
6. Partner Community 20% fee                                          Community
7. Additional 10 Object                                                   Community Add-On
8. Additional 20 Object                                                   Community Add-On
9. Force.com, Unlimited Ed                                           Force.com
10. Force.com Editon                                                          Force.com
11. Email Messages                                                         Marketing Cloud
29136966e-v1.07ab.xlsm
Both License Type and License Type 2 will be lists on a separate tab/sheet.
  1. So not on the userform? Or on a new sheet and the userform?
  2. Should I assume that the 'List' sheet will exist? In other words I don't need to create it?
  3. Should I replace the userform's 'License type' text box with a combobox that contains the List sheet's License Type entries?
  4. When a user selects something from that combobox should that value be put in the userform's 'License type 2' textbox?
1. On a new sheet and on the user form is correct

2. In the latest attachment has the list sheet.  I will be updating it with the list data as the actual list is much longer.

3. Yes, replace with combo box

4. Yes, that sounds like what I am looking for.  Im not sure how the combo box work but if it allows the user to select items under license type and then the associated  license type 2 name that appears should get populated into the license type 2 textbox.
Try the attached workbook.

In addition I have some suggestions for you:
  1. As I said the last time I answered a question for you, you should really change names like 'editstudent1' to something like 'txtDateQuoteRecvd' so that the names mean something ('txt' says it's a text box and the rest says what it contains). It will not be easy but it would make maintenance easier over the long run.
  2. The two horizontal scroll bars that appear because the data is wider than the listboxes, are not very useful since they are not coordinated. I believe that we could make it so that there is only one horizontal scroll bar.
  3. the License Type 2 textbox is too narrow, and so the placement of the controls on the right side of the userform should be adjusted.
29138866.xlsm
Thank you Martin and I agree with all your suggestion.  However, with changing the 'editstudent1' names. I hesitate to do this on my own as I do not want to mess up any of the script, but if you are able to update please do.
If you are happy with the current workbook then please select that post as the answer and I'll see what I can do with the rest.
The drop down under license type works fine and it does pull information into the License Type 2, but not the correct information.

If I select from License Type "Marketing Cloud, Enterprise Edition" what should populate into License Type 2 is "Marketing Cloud Add-on".  Right now it is pulling the exact information from what I selected from license type

Also I'm wondering for the License Type if I can see the entire list of licenses without having to scroll down to find and use a check box to select the license I need?
If I select from License Type "Marketing Cloud, Enterprise Edition" what should populate into License Type 2 is "Marketing Cloud Add-on".  Right now it is pulling the exact information from what I selected from license type
Oh, you're right. Sorry about that. I'll correct it.
Also I'm wondering for the License Type if I can see the entire list of licenses without having to scroll down to find and use a check box to select the license I need?
If your list is long and you don't want to have to scroll, then the userform would need to be a lot taller. How about if the license types were sorted? Also, once it is sorted, I might be able to make it so that if (in a slightly different type of combobox) when you enter a 'p' the list would automatically jump to 'Partner Community'.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Martin!  It is now pulling the correct data and yes lets try your suggestions.
Excellent job meeting my needs and offering additional suggested inputs for a cleaner workable spreadsheet.
What do you think of this layout?
 User generated image
  1. Would you want the "Pricing:" label moved to the right so that it aligns with the left edge of the Start Date value?
  2. Is the License Type 2 textbox too wide?
  3. Do you want all the textboxes at the right (including  License Type 2) to be the same size?
  4. Any other layout changes?
Some other possible layout changes:
5.  Move everything on the right hand side ('Monthly Price, etc.) down so they align with 'Asset ID'?
6.  Move the 'License Type 2' textbox down so that it aligns with the 'License Type' textbox?
7.  Add frames like the frame that appears when the red search button is clicked?
1. Would you want the "Pricing:" label moved to the right so that it aligns with the left edge of the Start Date value?
Actually the pricing label is not needed and can be removed.  I am open to any and all cosmetic changes that makes sense visually and ease in data input

2. Is the License Type 2 textbox too wide?
Marketing Cloud Add-on is the longest string I have seen for this field.  Therefore, it can be shorten.

3. Do you want all the textboxes at the right (including  License Type 2) to be the same size? For consistency it would be great, but I would like to be able see the entire entry so that maybe making the box height bigger as well on some.

Any other layout changes?

In the 'view all' Dashboard. I want the ability to show only certain records when needed lik Ref ID# Project Name, Total Price and Deploy.

I also, notice that when I enter a date into the 'Date Quote Received and then check the 'Add-New' the date is removed from the 'Date Quote Received' field.  Maybe this is just a matter of flipping the order

I am not sure if this considered part of the layout but  the view all and compact view seem to be switched around.

Again open to your recommendations on improving this view.
Some other possible layout changes:
5.  Move everything on the right hand side ('Monthly Price, etc.) down so they align with 'Asset ID'?
6.  Move the 'License Type 2' textbox down so that it aligns with the 'License Type' textbox?
7.  Add frames like the frame that appears when the red search button is clicked?

Yes, the above changes makes sense
3. Do you want all the textboxes at the right (including  License Type 2) to be the same size? For consistency it would be great, but I would like to be able see the entire entry so that maybe making the box height bigger as well on some.
What I meant here was that while the 'License Type 2' textbox can be shortened a bit from what appears in the picture, I would make all the rest of the textboxes on that size the same size as the 'License Type 2' textbox's new size..
Oh ok, that makes sense to make the text boxes the same size as the License Type 2 text box
Okay, let's talk about frames for a minute. Frames are usually used to group related items, and I assume that while all the textboxes on the userform are related to a particulate quote and so I could put one frame around all of them, it might be nice if the textboxes were grouped into 3 or 4 frames where the contents of each frame were closely related. If you want multiple frames then please let me know, using the label values, which controls should be in fame1 and which should be in frame2, etc and what the caption of the frames should say. Don't worry if the controls need to be moved around in order to group them.
If I am following Correctly, maybe something like this.

Frame 1: Order -  Ref ID# , Date Quote Received, Quote #
Frame 2: Customer Information - Project Name, Contract #, Asset ID, Org ID, Business Unit Contact
Frame 3: Product/Services -   License Type, License Type 2, Start Date, End Date, Original Term, Term, Qty, Total Price
I forgot to add to Frame 3: Monthly Price.

The Total price is a calculation that could be pulled into the userform from column N to see the full picture within the form
Let's leave Total Price for a later update.
sure.
So far so good?
User generated image
Okay, in this version.
  1. Frames added and controls rearranged and uniformly sized
  2. When the userform is opened, the 'List' sheet is sorted so that the 'License Type' entries will be in sort order
  3. 'License Type' combobox changed so that you can either directly select an entry, or you can start typing the name in the box.
  4. If you hover over the 'License Type' combobox, an explanatory message will appear.
29138866b.xlsm
Very nice!  Works great, and so much better and pleasing to the eye.
Martin,

When I tried to add a record, I couldn't add anything into the Project Name field.  also, When I clicked on the Add-record.  I got the following run-time error

run-time error: 2147024809 (80070057) could not find the specified object
 rData.Cells(lRw, iX).Value = Me("editstudent" & iX).Value
Put a breakpoint on that line by clicking in its lefthand margin and when the code gets there, hover over iX and let me know what the iX value is.
If I did it correctly I got a value of 5.  It freezes my computer and I have to go into my task manager to close excel down entirely to get oout of the spreadsheet.
It freezes my computer
It shouldn't do that, but that's something we can deal with later. BTW, what version of Excel are you using?

Corrected.
29138866c.xlsm
Unfortunately I am working with 2007, but at work its 2016.
Now when I try to enter Date Quote receive.  I am getting a Compile error: Can't find project or library.  The 'Private sub user form_Initialize()' is highlighted.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Still didn't work

In the references I saw MISSING: Microsoft Windows Common Controls 6.0 (SP6).  

It does work find on my work laptop
Martin,

Being able to pull up the License Type by typing the first letter is Great.

1.Is there a way to see the entire text without having to extend the box length.  Possibly similar to the hover message. Its hard to see exactly which license Type I need to select since the beginning on some are similar.

2. Also, having the ability to copy and paste into any of the userform fields.

3. Can I also get a subtotal on License Type 2

If these should be address as a separate "ask questions", please let me know.
Good news, it doesn't look like you need that reference so just uncheck it.

1.Is there a way to see the entire text without having to extend the box length.
There are several things I could do
  1. Make the whole userform wider so that the Product/Services frame and its content could be made wider
  2. Make the Order frame narrower and the Product/Services frame wider
  3. I could also add a horizontal scrollbar to the License Type combobox. In this picture I've scrolled to combobox to the right.
User generated imageIn any case if unchecking the missing reference works for you (if you're at work you can uncheck it and then do some testing even if it's not missing) please choose my most recent workbook as an answer and we can move on and I will include your choice above in the next update.

BTW I believe that the userform badly needs some date validations (and perhaps others) which would make sure that the start date is before the end date and perhaps that the start date must be on or after the Date quote received.
Thanks Martin!  I unchecked the missing reference and it worked.

3. I could also add a horizontal scrollbar to the License Type combobox. In this picture I've scrolled to combobox to the right.

I like option 3 adding a horizontal scrollbar, because I am not sure how lengthy the license string can get.

Yes, I agree with the data validations.
Great. Let's continue in this thread. In addition to the scrollbar, what would you like me to do next?
Next steps:

1. Have the ability to copy and paste into any of the userform fields.

2. Add a subtotal on License Type 2

3. Remove the Year field from the User form.  Not needed.

4. In the 'view all' Dashboard.  Have the ability to show only certain records when needed ie. Ref ID# Project Name, Total Price and Deploy.

**Important one and most complicated.   I inserted a tab on the attached work sheet called 1 Quote.  This shows the full picture of one entire quote that is received.  The first 3 lines are the official Quote information.  That gets entered into the Userform.  However, after I enter it in the user form I have to then convert it 12 month/year to show when a year has expired and we are no longer responsible for payment,  The Original term on this quote says 27.13 which converts to about 2 years and 26 days approx.  I added the calculations I use to derive at this.  

It is a lot of manual effort. Do you think there is a way that I can automate this a bit.  I hope this makes sense.  Its not easier to explain, but hopefully seeing it will help some of what I have to do to accomplish this.
29138866d.xlsm
How about we work on just the first 3 for now? I need more details about "Add a subtotal on License Type 2".
Ok.  Right Now when clicking on the subtotal button it creates a total line for each change in Ref ID#, and for Project Name.  I would also like to have total for each change in License Type 2 as well.
Please manually add the total lines to this workbook. I believe column 'P' is sorted properly.
Markup.xlsx
I attached the file, but in thinking about it more clearly it may make sense to keep the totals the way they are as I don't want the sheets to get to messy.

But maybe there is a way where I can choose which subtotal I want to view. For example, if I just want to view Ref ID # Total and a grand Total and then Project Name Total and Grand Total and License Type 2 etc... through a button.

Open to your thoughts.
Markup.xlsx
How about a second subtotal button with the new one being the new subtotaling? If so, any idea what the buttons should say?
wow! got me there.  I ask the buttons can be rename later.

I need to think a bit on the name
In the markup.xlsx you sent me there are two columns named License Type 2! I hope that you inserted the first one (column 'F') accidentally because dealing with adding a new column will be somewhat difficult and so I hope you can send me an updated markup without that column.
User generated image
oh I am sorry.  I copied the column as I thought it made more sense to be next to the License Type and before the total price column.

But if it doesn't need to be moved.  I'm ok with that as well.
Would doing it this way be OK?
User generated image
BTW, what do you think of this?
User generated image
Yes, I think I can work with that.  Will I be able to subtotal by the RefID# as well?
I'm not sure how the License Type 2 subtotal sheets should be sorted . The existing subtotaling sorts on Project Name, followed by Ref ID# and finally Start Date.

Should the new sort be by License Type 2, followed by Ref ID# and finally Start Date? Or like the existing? Or???
I think like the existing.   Im not sure how it would actually work or even look, but it seems to me that  it would be difficult to present all three subtotals at the same time. Although,  you probably have a solution for this. I think as long  as all three of the change categoris are sorted and then grouped giving the ability to subtotal by reference ID# and  possibly remove that  subtotal and the select the button to subtotal by license type 2 and so on wouldn't matter so much the order.  The original data sheet is well over 500 records. I apologize if I'm not helpful in determining this structure.
Sorry but I'm still confused so let me ask the question this way.

As I said above, the existing subtotaling sorts on Project Name, followed by Ref ID# and finally Start Date.
In the sorted results:
  1. A Ref ID# subtotal is shown when the combination of Project Name and Ref ID changes
  2. A Project Name Total is  shown when Project Name changes
  3. At the end a Grand Total is shown

So please try several sort combinations (if you need to) and describe what you need like I just did.
I am having a difficult time with this one. Maybe leaving the existing way is the best solution and possibly creating a dynamic pivot table to capture all three  scenarios would be the better. However, I don't know much about pivot tables. Truly apologize as I am at loss trying to  come up with sort combinations to give  what I am looking for.

However, I thought possibly if the sort

1. License type 2 subtotal is shown when combination of license type 2 and project name changes
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Martin!  This will work just find.
4. In the 'view all' Dashboard.  Have the ability to show only certain records when needed ie. Ref ID# Project Name, Total Price and Deploy.
Do you mean that when you click View All Columns that you want to be able to select just certain Ref ID#s, or just certain Project Names, etc?

**Important one and most complicated.   I inserted a tab on the attached work sheet called 1 Quote.  This shows the full picture of one entire quote that is received.  The first 3 lines are the official Quote information.  That gets entered into the Userform.  However, after I enter it in the user form I have to then convert it 12 month/year to show when a year has expired and we are no longer responsible for payment,  The Original term on this quote says 27.13 which converts to about 2 years and 26 days approx.  I added the calculations I use to derive at this.
Questions about the above:
  1. You only highlighted one LicenseType 2 for the quote. How will I know which one you want to do the "1 Quote" on, or will it always be for the whole quote?
  2. "I added the calculations I use to derive at this". Where?
  3. Why are rows 46 to 51 the same color when they are two different years?
4. Yes

Questions about the above:
1. You only highlighted one LicenseType 2 for the quote. How will I know which one you want to do the "1 Quote" on, or will it always be for the whole quote?

It will always be for the whole quote.  each quote will have any where from 1 to 5 line items or more.  The start and end date are the drivers.  While the quote may have many line items the start and end date will be the same on each line. ie., 3/14/2019 to 3/08/2021, which then needs to be broken into years

2. "I added the calculations I use to derive at this". Where?

What I mean't by this is that in order to match the quote line item amount after breaking out the years  I have formula in Column U that is part of the Total price formula.  

3. Why are rows 46 to 51 the same color when they are two different years?

There is no reason necessarily behind the color other than trying to show you how it's broken out from row item 1,2,3.
Okay one more thing for now. Currently the "View all columns" and its companion are outside of the "'Commands' frame. Would you mind if I replaced them with a button in that frame? I also plan on adding a '1 Quote' button (better name?) in that frame. That will make the 'Commands' button area larger than the 'Search' area and so for esthetic reasons would you care if I moved the two images to the left side of the frame?
Additional clarification for rows 46 to 51.  There may not be a complete full year that will be broken out within the start and end dates.  For instance rows 49 to 51 is on for approximately 2.5 months (1/1/21 to 3/14/21), but has to be included as it makes up the complete quote amount as well as the entire quote start and end date of 12/11/18 to 3/14/21.

I hope that makes sense.
No I do not mind at all.  Considering what you have done thus far is leaps and bounds from what I could do.

Button - Single Quote or Quote Breakdown.  I'm open on this as well
I just found what may be a problem in your existing code. If you make a changes in the form and then press View all Columns, followed by Compact view, the changes are lost. Let me know if that's what you want to have happen.

Also you have a form called OLDfrmeditrecord. Do you still need it?
No that's not what the view all columns was intended to do.  I basically was looking to search on a particular column and have the ability to see certain information from that quote along with the total price of the quote itself.

for example if I searched by Ref ID# 1(which is considered one entire quote).  I want to be able to choose any related columns associated with that quote such as the license Type 2, project name, Qty, Monthly price and Total Price with a grand total showing in the view screen for that one one Quote.

The OLDfrmeditrecord is not needed.
If you have a "to do" list for this workbook, please add "View all Columns, followed by Compact view -> changes lost" to it and we can deal with that later.
In addition to the above, the listbox on the user form carries only the first 19 columns of the data, with the last column being 'Original Term", while the example you show all the columns. Do you need the '1 Quote' sheet to show all the columns or just those in the listbox?
Just those in the list box
The Original term on this quote says 27.13 which converts to about 2 years and 26 days approx
In that case how many months should be shown?

And do I need to break out each line? In other words if there were a total of 5 lines in the quote and all the original terms were 12, would the results contain 60 rows?
The 27.13 converts to about 2 years 3mos. I'm not sure how to verbally explain it in terms of months, but maybe the attachment will help. I tried to layout how the term is converted to months.
29138866d.xlsm
And do I need to break out each line? In other words if there were a total of 5 lines in the quote and all the original terms were 12, would the results contain 60 rows?

No in this case the term 12 equals to 1 year or 12 months and therefore the lines will equal only to the 5 lines. For instance 1/1/2019 to 12/31/2019 = 12 months.  This will only change if the date on the quote extends over a 12 month period. If the term says 24 months then the dates more than likely would be from 1/1/2019 to 12/31/2020 and then the 5 line quote will be copy 5 more times to account for the next year totaling 10 lines at that point and so on. Where it get a bit tricky is when the term is not exact like the 27.13

The start and end dates are the driver as they should equal the term
Always looking for a better easier way to calculate this.
I'm still not understanding. Could you attach a workbook where the RAW_DATA contains the unmodified Q-7657895 quote plus one one more where the original term in that second quote is not all the same?
I attached the unmodified quote Q-7657895.

one one more where the original term in that second quote is not all the same?

regarding additional quote where the original term is not the same.  This would be a rarity and really should not happen. For every quote the term will be the same for each line item within the quote itself.  So if the a quote has 5 line items the term will be the same for all line items. But I did provide one that has happen in the past years
29138866e_unmodified-quote.xlsm
Thanks. When the Original Term is 27.13, how many months is that? 27? 28?
I hope this is what you meant by to do list.

1.      View all columns followed by Compact View
2.      View specific columns (choice selection)
3.      Add Comment field to user form. Note: Comments doesn’t need to be added to the RAW_Data
4.      Link to quote document
a.      Add a report page button to another User form that displays
b.      Headers across the form that will show
i.       
Total number Quotes Received
ii.      Total amount in Quotes Received to-date
iii.      Total amount in  Active Quotes
iv.      Total amount in Expired Quotes
c.      
charts to display Historical Data:
i.      
Total price By license Type 2 (inform of a pie chart) License type 2, total price and Qty with option to pull by project name
ii.      Total price by Project Name  (inform of a pie chart) project name, total price and Qty with option to pull by project name
d.      
charts to display by year:
i.      
Total price By license Type 2 (inform of a pie chart) License type 2, total price and Qty with option to pull by year and project name
ii.      Total price by Project Name  (inform of a pie chart) project name, total price and Qty with option to pull by year and project name
When the Original Term is 27.13, how many months is that? 27? 28?

It has to be exact. So it is 27 months and whatever .13 translate to which I believe is 0.13 month or 4 days
Perhaps but to that in my opinion the following should be added
  1. Userform date and other validations for required fields (if there are any) should not be blank.
  2. Change names of controls to meaningful names.
  3. Only one scrollbar on the userform
  4. In the 'view all' Dashboard, add the ability to show only certain records when needed like Ref ID# Project Name, Total Price and Deploy.
  5. New field on the userform?
About the 27.13 I guess I should have asked how many years should that be broken down to. 2? 3? 2 years 3 months? 2 years 4 months? Or maybe I'm just confused.
Perhaps but to that in my opinion the following should be added
Userform date and other validations for required fields (if there are any) should not be blank.
Change names of controls to meaningful names.
Only one scrollbar on the userform
In the 'view all' Dashboard, add the ability to show only certain records when needed like Ref ID# Project Name, Total Price and Deploy.
New field on the userform?

Agree with all the above
27.13 Translate to 2 years 3 months and 4 days

Here is the formula if you insert the 27.13 in say cell A1
=INT(A1/12)&" Years, "&INT(MOD(A1,12))&" Months, "&ROUND(30*MOD(A1,1),0)&" Days"

Yes, it needs to be broken out into years.  The current formula I have does address original term once I change the start and end dates, but this is a manual copy and paste process that I am trying to eliminate if possible.
27.13 Translate to 2 years 3 months and 4 days
I understand that. What I'm trying to get at is how many rows of data does that one row break out to the 1 Quote sheet?
The entire quote makes up the 3 lines under term 27.13. So, including the oiginal 3 lines from the one quot there should be a  total of 12 lines/rows.

3 lines will  go towards  year 2018 - ( 12/11/18 - 12/31/18) then the same
3 lines will go towards year 2019 (1/1/19 - 12/31/9) then another
3 lines towards 2020 - (1/1/19 -12/31/20) and last
3 lines towards 2021 - (1/1/21 -3/14/21)


If you only referring to just one line from the qoute  then it will be a to al of 4 lines/row. 1 row for each year to complete  the start and end dates of the qoute.
Okay, the fog is clearing now but I have at least one more question.

Why in the first row of the Q-7657895 quote do you change the 'Start and End Conversion to Month' value of 0.67741935 to 0.63 when in fact 21 days divided by 31 days is 0.67741935 days?
Start and End Conversion to Month' value of 0.67741935 to 0.63 when in fact 21 days/31 days is 0.67741935 days?
Is this your solution?

Good question, and you will probably be a bit confused by this as well.  We do not have control over the terms from the vendor. The period for entire Q-7657895 is from 12/11/2018 - 3/14/2021 which equals to 2years, 3months, 3days, but the 27.13 is equal to 2years, 3months, 4days. The total price needs to match up with the quote for that period and line item which would be $2,275.60.

If I calculate 0.67741935* Monthly price * Qty it will = $2,446.88, which does not match up to the quote.  Therefore, I had to come up with a rounding formula and then reduce the difference an then calculate 0.63*monthly price * qty which = to the quote amount price $2,275.60.  all the remaining lines can be calculated of the conversion date column.

Please see see attachment col N and S

Also, for  0.63 I get 20 days
29138866d.xlsm
Given that there will be four breakout lines from the first line of the  Q-7657895 quote and that the middle two will be 12 months each, does it matter if the first and last differ from your calculation as long as it all adds to $69,995.40?
It shouldn't matter as long as the bottom line total matches the quote amount.  Usually there is not a need to make adjustments to the formula.

The discrepancy in the cost usually  is not that significant prior to adjusting.
So, I think it will be ok if those lines differ my calculation.
That's good.

Trivial question, can I change the 'Add Quote' button to 'Quote Maintenance" since it does more than just add quotes?
Yes you can change that button
Project update. I'm off by a penny.
Lol...Geez. I'm not sure how your writing the formulas, but I always  had to adjust by manually adding the difference.  I have being trying to figure out a formula that can handle the small differences.
I noticed that the total on the RAW_DATA sheet is 69,995.40. You showed 69,995.19 so I guess 69,995.20 is good enough, but I could adjust the last row of the quote breakout (via code) so that the total will match the RAW_DATA total.
It should match up to the quote amount 69,995.19.  We will not pay more than than that
I believe the attached works for quotes Q-7657895 and Q-8796546. The penny difference in Q-7657895 is adjusted for by subtracting the difference between the calculated total and the quote total If they are different (I assume the difference, if there is one, will always be a penny, but I calculate it anyhow) from the first segment's total and from the grand total.

Quote NA-001 gives an error, I believe because it contains more than one project whereas the above two don't. Could you create a workbook that contains just the first 13 rows of quote NA-001 and show me what the 1 Quote sheet should look like for that modified quote? I don't need any explanations, just a picture of the result.
29138866f.xlsm
Martin,

I know you just need a screen shot and I can provide later.  But keep in mind I provided fictional data and the Quote for rows 4 - 40 all have NA-001. In reality it should tie to the ref# and look more like NA-001 to match Ref# ID 1, NA-002 Ref ID# 2, NA-002 Ref ID#3 and so on which makes them separate quotes.
Oh. okay, no screen shot needed!
Ok, great!
Well, I take that back, but this should be easier. Please show me a picture of what the breakdown of ref ID 6 should look like.
Some findings after testing the workbook:

1. When I enter one line from a quote the data is added to the RAW_DATA sheet, but not to the other sheet unless I  click on the project Name Subtotal Button.  The same holds true when I try to delete a line. I have to also manually removed the line from the data breakdown sheet as well.  Once delete the data is not removed or added automatically across sheets.

2. The Quote Maintenance breakdown  data is added to the 1 Quote sheet.  Once its broken down the data rows should get added to the RAW_DATA, ALL, Active or Expired and override the original line that was added.  As that line has now been broken down and no longer required as the breakdown is the replacement data.

3.  What I think should happen is the 1 Quote sheet can be rename to Salesforce Quotes.  When a user add a new quote it transfers to that sheet and the breakdown gets added to the RAW_DATA, ALL, Active or Expired. This way we can keep the original quote data intact and have a compare with the breakdown data.

4. In addition, if I use the start and end date of 1/11/2018 - 3/13/2021 with a original term of 27.13 the breakdown for the firs year returns 1/11/2018 - 1/31/2018.  It should return 1/11/2018  - 12/31/2018 and gave me #value! for Col U - W.  I deleted and tried it again and I got the same thin for the first line of the breakdown, but this time it converted the date to 3/11/2018 - 3/31/2018

5.  Also, after the break down it converts the original term  from a number to a currency, but this is not all all the lines just the first and last where there is a change from 27.13.

6.  When I try to perform a search on the new added quote line.  I received the Run-time error '91 - object variable or with block variable not set - "If oWs.Filter Mode Then

That's all I have for now.
When I enter one line from a quote the data is added to the RAW_DATA sheet, but not to the other sheet
Once its broken down the data rows should get added to the RAW_DATA, ALL, Active or Expired and override the original line that was added.
You never mentioned either of those as a requirement, but I'll look into it.
In addition, if I use the start and end date of 1/11/2018 - 3/13/2021 with a original term of 27.13 the breakdown for the firs year returns 1/11/2018 - 1/31/2018.
It doesn't for me, but it's important to note that currently only ref ID's 10 and 11 work and I need to see what ref ID 6 should look like before I can fix that.
User generated image
Also, after the break down it converts the original term  from a number to a currency,...
I didn't notice that and I'll fix it.
When I try to perform a search on the new added quote line.  I received the Run-time error '91
Will fix.
I'm not sure how to use the prnt screen from my home PC to insert screen shots.  So I hope it comes through ok.  Other wise I will have to seen the workbook.

Also, I changed the start and End date as well as original term so that the total price is a bit more meaningful.

User generated image
Thanks. Unrelated question: when the userform opens the last row in the data is selected. Would you rather it be the first row?
If the form opens on the first row when I add a new quote will it autio default to next record entry? And If so, then yes it can be changed to open on the first row.
I think the question of what happens after you add a new quote is unrelated. Currently in the workbook you have, when you open the form for the first time, the last row of the listbox is selected, and I'm asking if you'd rather it were the first row. By the way, I solved the (tough) problem of the new data disappearing when you do 'Add New' and in my new workbook when you 'Add New' the new data stays on the userform and the last row in the listbox (which is the new data) is selected.

So to ask again when you open the form, would you the first row of the listbox to be selected?
Yes sure let's do it that way.

This is what happens when you're not a developer or coder.  Different levels of processing information...lol  :)
In your picture you show 5 segments where I believe the first segment is the original data. True?  If so do you want to show that segment when the  report is done?

Another important question that has been plaguing me is that I need I need to know ahead of time how many segments I'll need. In ref id# 10 I calculated it by subtracting the year of the start date from the year of the end date and got 4 (which worked fine). How do I do it in ref id# 1 since the years are the same?
No, I think the original  data should move to the 1 Qoute sheet and the breakdown added to the Raw_Data.

Not sure if I am following the second question.  The data  your working with are not true quote data, quote 10, 11 and screen shot of quote 1 would be what a true quote would look like.  
However, a quote can come in for a 1 year period or even less than a year. The less than year would be unlikely but could happen.  There shouldn't be exact same dates and if so its incorrect.  At the moment I don't have the workbook in front me to see what you mean exactly but if it says something  like 6/1/2015 to 6/30/2015 It's incorrect.  Even 6/1/2015 to 12/31/2015, which is about 6 months for the 1 year in 2015 and which the org term  would say 6. If this the case there is no breakdown same would apply if it's for 1 year. The term would be only 12 months  and no breakdown required.  A breakdown is needed when the term exceeds a one  year period.

You can change the data you have to present different quote date and term change  scenarios. So that code can account for it
No, I think the original  data should move to the 1 Qoute sheet and the breakdown added to the Raw_Data
Again I think this is a new requirement because all this time I've been working on the assumption that the breakout, at least, should go to the 1 Quote sheet, so for now I'm going to continue doing that.

In the attached workbook, please confirm (or modify and upload) that it is what a production quote would look like.
Ok, I apologize for not being clear.
The data you have in the workbook essentially already have the quotes broken down already. I'll  just copy and paste from the 1 quote to raw _dara sheet to get it to perform correctly.  

I didn't receive the attachment.
I can't attach files or screen shots from work. If you still require an Upload I can do when I get home from work.

1. Col K row 1  replace 24 with 12
2. col. N row 1- 5 replace 26250 with 4500
3. Col X row 1- 5 replace (-1149) with (-1174)

Everything else looks good.
I'm going a bit nuts here, so here's what I need you to do.
1) With my latest workbook (29138866g.xlsm), do a Quote Breakdown for Ref ID# 10
2) Ignoring for now the fact that you want the results to be in the RAW_DATA sheet, please tell me what if anything is wrong with the result, and why
3) The results you showed me in the picture for Ref ID 1 (note: Ref ID 1 and not 10) don't make sense to me, so make sure that what's there is actually what would be in a production quote, change it if necessary, and then in a new sheet please manually create a report that you would expect from that quote.
4) Attach the updated workbook.
Ok, no problem.

Did you attach the latest workbook?
Martin, I didn't get the attachment 29138866g.xlsm
Sorry, I meant 29138866f.xlsm and I know about the currency problem in column 'S' of that workbook.
Ok.  I will work on it.  Thanks.
then in a new sheet please manually create a report that you would expect from that quote.

I am not clear on this portion.  What specifically do you mean by "create a report"?  I know where the placement of the expected quote should go, to which you would like for me to ignore for now.  So I am a bit unclear on this part.
What I meant was for you to go to the 1Quote sheet and manually create what a correct Ref ID 1 quote would look like if you had pressed the Quote Breakdown.
Maybe it would be easier if after you verified that the data on the RAW_DATA sheet for ref ID 1 was correct, that you first press the Quote Breakdown button, and if the results are not to far off, then manually correct the data on the 1 Quote sheet.
Ok, I think I understand now.
Okay, thinking about this some more could you do the first two parts first which were the following?
1) With my latest workbook (29138866F.xlsm), do a Quote Breakdown for Ref ID# 10
2) Ignoring for now the fact that you want the results to be in the RAW_DATA sheet, please tell me what if anything is wrong with the result, and why
When I try to open the form for workbook (29138866F.xlsm) I get the below error message:


Private Declare PtrSafe Function LockWindowUpdate Lib "USER32" (ByVal hwndLock As Long) As Long
Remove that line.
1. Missing first row of Quote from RAW_DATA (Row4).
2. Original Term show in Currency for rows. ( I believe this has been fixed)

Everything else is fine
29138866f_quote10.xlsm
Maybe the data has changed but I only see 3 rows.
User generated image
Yes, there are only three rows. Per your ask I removed all the other data from the RAW_DATA sheet and re-entered the data for quote 10 and then ran the quote breakdown and only two lines from the quote appeared on the 1 Quote sheet.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok thanks. I will take a look at it. Regarding the Update button I didn't  notice if it greys  out or becomes inactive when the add new is selected.  I don't think it will be a problem  but having the inability to select it once the add new is selected to me is a better functionality especially since it's primary use is to make changes to an already existing line item.
Everything looks good after the breakdown except for col Q, W and X

Once the quote has been broken down the dates also should reflect this as well as the expiry days.  I think this was working correctly before.

Col Q = 2018, 2019, 2020, 2021
Col W = 122018, 122019,122020,122021
Col X - (End date - Today) = 81, 284, 650, 723 - this drives the Col O (Active and Expired)
Col X - (End date - Today) = 81, 284, 650, 723
Shouldn't that be -81, etcetera? And since you posted yesterday I think the first value should have been -80. Am I correct?
I don't know if you saw my last post but try this.

I also changed column ‘V’ so that it actually shows the month of start date and changed the heading from “Month1 ( off start date)” to “Month 1  (of start date)”

BTW, back a few posts I mentioned that 'Update' is available when 'Add New' is clicked" and as far as I can tell both buttons do exactly the same thing when adding a new quote, so I would suggest that when adding new that 'Update' be grayed out.
29138866h.xlsm
Yes you are correct.  It s/b -81
Thanks Martin.  Changing the 'Update' button makes sense.
Please see attached workbook.  This is the  result that I got when I tried to add a new quote 100.  There are columns that where not part of the user form that use to at some point get copied down to the new add row on the RAW_DATA sheet and now longer getting copied down.  Also, the 1 quote sheet did not breakdown the quote at least i can tell if it did or not.  I am not sure what else going on or how to interpret/explain it, reason for the attachment.

Also, when I tried to search  I got the following Run-time error '91
 Object variable or with block variable not set - If oWs Filter Mode Then.

The search fields also does look to be picking up the right fields.
29138866h.xlsm
Let's talk about column 'N'.  It used to be a number copied directly from the userform. I changed 'N' on the userform to be a formula rather than a number and that may be  the reason that it's not showing up. Do you want 'N' on the RAW_DATA sheet to be a number or a formula?
Actually L (monthly price) is on the user form and it should be a number not a formula.  N is the Total price which is not part of the user form and is a formulated number.
Actually L (monthly price) is on the user form and it should be a number not a formula.
I agree and it is.
N is the Total price which is not part of the user form and is a formulated number.
I agree. I assume that the answer to my question is "formula".
Yes
Okay I found the problem. A while back when I didn't understand the workbook as well as I do now, I made a one-line change that affected the creation of a new quote. I also learned today that the way writing of the new quote works is that the first thing the code does is to copy the previous row to the new row including the formulas, and that change screwed that up.

Since the code copies the data from the previous row to the new one it's necessary that all the fields on the userform be filled in so that all the copied data is replaced, and so I believe that the next thing we should do is to add validations that would occur when the Add New button is pressed that would not let the process continue until all is well.

Also an item that you should add to your To Do list is that currently the comment from the previous quote is being copied to the new one and that there's no way now to add a replacement comment (or blanks).

The attached workbook grays out ‘Update’ when ‘Add New’ is clicked.
29138866i.xlsm
Ok, undertood.
The new work book is performing the same way as the previous one.  The 1 quote is not working properly.  The breakdown is not grouping together and the subtotals doesn't seem to be working correctly.  Also, I am still not able to search.

I keep getting Run-time error '91
 Object variable or with block variable not set - If oWs Filter Mode Then.
Did you add new data to the workbook?

I also just realized that I don't know what you mean when you say "search".
Yes, I did add new data.  On the form there is a search icon providing a drop down list of options to search on.  When I try to search Ref# or Quote I get a run time error.
My saying that I didn't know what search was, was dumb; of course I did. In any case I corrected the problem with search and it will be in my next upload.

Please attach the workbook containing the new data.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you Martin!  Everything looks to work perfectly so far.  Excellent work!