jreilly851
New Member
- Joined
- Aug 18, 2014
- Messages
- 7
Hi guys,
I know someone out there can help, and most likely the solution is right under my nose! Here's my problem:
<gs id="599a80ab-3dc0-4be6-9580-6cb172c5fdca" ginger_software_uiphraseguid="b4acff07-67dd-4d48-8ca8-8220b278e8cc" class="GINGER_SOFTWARE_mark">I</gs> have a <gs id="bf461e18-cb18-4c7d-a485-2ecabcdbe0f1" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="83409ed4-08d5-4948-956e-30066b0838d5" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">userform</gs></gs> created, see the link below, and I'm trying to pull the SELECTED VALUE (you click on 1 line, and it becomes highlighted, or "selected") from the large multi-select listbox (aptly named "listbox1"), and do a <gs id="011ab240-ceb1-470c-93f9-0cbcfa0dbb61" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="8311260b-5993-4dd9-a71d-1c2090200cc2" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">Vlookup</gs></gs> on a specified sheet "Hierarchy Codes," range B<gs id="cdfee1aa-fd43-4c73-9a16-119e5c11a4bc" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="268732ae-6b8b-45a2-b102-0615f7e3418d" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">:</gs></gs>C, and populate the result of that <gs id="278b247f-7e8f-4a83-9a20-aeeb63b21792" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="97d2a064-e7cd-4dd0-958b-e25657ebe199" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">vlookup</gs></gs> into textbox1 over there to the right, <gs id="16d7e388-b1e2-424a-9217-b95f3e44cfca" ginger_software_uiphraseguid="c7371bff-8987-4d43-82cd-a405ef0171c5" class="GINGER_SOFTWARE_mark">labeled</gs> "selected hierarchy last 12 months sales." In <gs id="a6f68644-dc73-49ed-ae8d-528a097ffdd5" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="6dd0d732-18d7-41d9-8a9f-8f937326f7ea" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">essense</gs></gs>, I'm trying to accomplish....<gs id="592fcb0b-011e-4d3f-ad18-e045f08e98b2" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">.</gs><gs id="e5b8a7cc-1b96-450e-bed0-adde427405f0" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="d4d300e9-250d-4e40-aa57-f8a83bdc1015" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">vlookup</gs></gs><gs id="5d769b5b-4270-4523-bae6-4397d669af20" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="849ab024-f341-460c-a45e-1a22605ce9d5" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">(</gs></gs>something here to extract the <gs id="e58d8f44-806f-4b80-ac7c-2f9def8035ca" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="1e3eae1a-abde-4bf9-a732-da8dd725aa5d" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">listbox</gs></gs> selected text, Sheet<gs id="f29df8aa-cbb0-434b-bcc8-a3de272527be" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="c10f621c-841b-4c19-8314-29bd67c3bfe4" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">(</gs></gs>"hierarchy codes") B<gs id="b531a01e-f049-47d9-a416-c53d20efbd52" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="99fdba71-a735-43d7-a183-093101741368" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">:</gs></gs>C, 2, false)
The following textbox2, labeled "Total account sales last 12 months," needs to be populated by doing some kind of a <gs id="d9c1af21-0dda-4eba-aadf-f2bea7ebb892" ginger_software_uiphraseguid="39a58848-3d5d-4144-9f57-83d5026044ff" class="GINGER_SOFTWARE_mark"><gs id="67e04707-d34f-4118-9e7b-84d0205c608e" ginger_software_uiphraseguid="e955dec4-0bc3-4d13-9f71-6a8da13f39a3" class="GINGER_SOFTWARE_mark">worksheetfunction</gs></gs><gs id="b620fc98-340f-40ff-bbf5-72447dc985c0" ginger_software_uiphraseguid="39a58848-3d5d-4144-9f57-83d5026044ff" class="GINGER_SOFTWARE_mark"><gs id="c9b9d890-fd07-4148-ae6f-fb60227dd105" ginger_software_uiphraseguid="e955dec4-0bc3-4d13-9f71-6a8da13f39a3" class="GINGER_SOFTWARE_mark">.</gs></gs><gs id="5b2b7a83-ad16-4c38-9c02-69483863322f" ginger_software_uiphraseguid="39a58848-3d5d-4144-9f57-83d5026044ff" class="GINGER_SOFTWARE_mark"><gs id="0175c117-966f-4d14-a2ef-83ee25fe0e3c" ginger_software_uiphraseguid="e955dec4-0bc3-4d13-9f71-6a8da13f39a3" class="GINGER_SOFTWARE_mark">sum</gs></gs> code by summing up the total of column M on sheet "Account Discounts Raw."
The third and final textbox there to the right simply needs to divide the result of textbox1 by the result of textbox2 to give you the % of total sales.
https://drive.google.com/file/d/0Bx6mAgyyvtrQNE1KVXJ3VXJEOXc/view?usp=sharing
Here is the code I've played around with for the last 24 hours or so.....
Thank you in advance!
I know someone out there can help, and most likely the solution is right under my nose! Here's my problem:
<gs id="599a80ab-3dc0-4be6-9580-6cb172c5fdca" ginger_software_uiphraseguid="b4acff07-67dd-4d48-8ca8-8220b278e8cc" class="GINGER_SOFTWARE_mark">I</gs> have a <gs id="bf461e18-cb18-4c7d-a485-2ecabcdbe0f1" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="83409ed4-08d5-4948-956e-30066b0838d5" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">userform</gs></gs> created, see the link below, and I'm trying to pull the SELECTED VALUE (you click on 1 line, and it becomes highlighted, or "selected") from the large multi-select listbox (aptly named "listbox1"), and do a <gs id="011ab240-ceb1-470c-93f9-0cbcfa0dbb61" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="8311260b-5993-4dd9-a71d-1c2090200cc2" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">Vlookup</gs></gs> on a specified sheet "Hierarchy Codes," range B<gs id="cdfee1aa-fd43-4c73-9a16-119e5c11a4bc" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="268732ae-6b8b-45a2-b102-0615f7e3418d" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">:</gs></gs>C, and populate the result of that <gs id="278b247f-7e8f-4a83-9a20-aeeb63b21792" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="97d2a064-e7cd-4dd0-958b-e25657ebe199" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">vlookup</gs></gs> into textbox1 over there to the right, <gs id="16d7e388-b1e2-424a-9217-b95f3e44cfca" ginger_software_uiphraseguid="c7371bff-8987-4d43-82cd-a405ef0171c5" class="GINGER_SOFTWARE_mark">labeled</gs> "selected hierarchy last 12 months sales." In <gs id="a6f68644-dc73-49ed-ae8d-528a097ffdd5" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="6dd0d732-18d7-41d9-8a9f-8f937326f7ea" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">essense</gs></gs>, I'm trying to accomplish....<gs id="592fcb0b-011e-4d3f-ad18-e045f08e98b2" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">.</gs><gs id="e5b8a7cc-1b96-450e-bed0-adde427405f0" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="d4d300e9-250d-4e40-aa57-f8a83bdc1015" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">vlookup</gs></gs><gs id="5d769b5b-4270-4523-bae6-4397d669af20" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="849ab024-f341-460c-a45e-1a22605ce9d5" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">(</gs></gs>something here to extract the <gs id="e58d8f44-806f-4b80-ac7c-2f9def8035ca" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="1e3eae1a-abde-4bf9-a732-da8dd725aa5d" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">listbox</gs></gs> selected text, Sheet<gs id="f29df8aa-cbb0-434b-bcc8-a3de272527be" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="c10f621c-841b-4c19-8314-29bd67c3bfe4" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">(</gs></gs>"hierarchy codes") B<gs id="b531a01e-f049-47d9-a416-c53d20efbd52" ginger_software_uiphraseguid="1fac60ba-1652-4423-9ee5-351f7c62f0b7" class="GINGER_SOFTWARE_mark"><gs id="99fdba71-a735-43d7-a183-093101741368" ginger_software_uiphraseguid="ee711296-42c5-4261-830c-50f6a1e4327f" class="GINGER_SOFTWARE_mark">:</gs></gs>C, 2, false)
The following textbox2, labeled "Total account sales last 12 months," needs to be populated by doing some kind of a <gs id="d9c1af21-0dda-4eba-aadf-f2bea7ebb892" ginger_software_uiphraseguid="39a58848-3d5d-4144-9f57-83d5026044ff" class="GINGER_SOFTWARE_mark"><gs id="67e04707-d34f-4118-9e7b-84d0205c608e" ginger_software_uiphraseguid="e955dec4-0bc3-4d13-9f71-6a8da13f39a3" class="GINGER_SOFTWARE_mark">worksheetfunction</gs></gs><gs id="b620fc98-340f-40ff-bbf5-72447dc985c0" ginger_software_uiphraseguid="39a58848-3d5d-4144-9f57-83d5026044ff" class="GINGER_SOFTWARE_mark"><gs id="c9b9d890-fd07-4148-ae6f-fb60227dd105" ginger_software_uiphraseguid="e955dec4-0bc3-4d13-9f71-6a8da13f39a3" class="GINGER_SOFTWARE_mark">.</gs></gs><gs id="5b2b7a83-ad16-4c38-9c02-69483863322f" ginger_software_uiphraseguid="39a58848-3d5d-4144-9f57-83d5026044ff" class="GINGER_SOFTWARE_mark"><gs id="0175c117-966f-4d14-a2ef-83ee25fe0e3c" ginger_software_uiphraseguid="e955dec4-0bc3-4d13-9f71-6a8da13f39a3" class="GINGER_SOFTWARE_mark">sum</gs></gs> code by summing up the total of column M on sheet "Account Discounts Raw."
The third and final textbox there to the right simply needs to divide the result of textbox1 by the result of textbox2 to give you the % of total sales.
https://drive.google.com/file/d/0Bx6mAgyyvtrQNE1KVXJ3VXJEOXc/view?usp=sharing
Here is the code I've played around with for the last 24 hours or so.....
Code:
Private Sub Listbox1_change<gs id="522bf4c5-90d1-4e83-bd3e-d766c8863452" ginger_software_uiphraseguid="4bd5f1f7-e0f0-4e2e-9565-a2b6639e69f9" class="GINGER_SOFTWARE_mark">(</gs>)
Dim ws As Worksheet: Set <gs id="b0854f68-2432-4baa-a167-d5a7860998cf" ginger_software_uiphraseguid="d32c1b23-95d9-437e-9d6a-978a4f0f392e" class="GINGER_SOFTWARE_mark">ws</gs> = Sheets<gs id="93008d08-5705-485c-8d2c-18d21eb06971" ginger_software_uiphraseguid="d32c1b23-95d9-437e-9d6a-978a4f0f392e" class="GINGER_SOFTWARE_mark">(</gs>"Hierarchy Codes")
Dim <gs id="802f61fc-03f3-4195-9a15-b080ec425c07" ginger_software_uiphraseguid="f42cc819-7f8e-4f78-85d5-2cdb3da68894" class="GINGER_SOFTWARE_mark">rngLook</gs> As Range: Set <gs id="64773c85-b6fd-4a2c-ab21-f8a2ff621d83" ginger_software_uiphraseguid="f42cc819-7f8e-4f78-85d5-2cdb3da68894" class="GINGER_SOFTWARE_mark">rngLook</gs> = <gs id="5a849e27-6298-4a3f-a4cd-7e3bcda3d0eb" ginger_software_uiphraseguid="f42cc819-7f8e-4f78-85d5-2cdb3da68894" class="GINGER_SOFTWARE_mark">ws</gs>.Range<gs id="5bd4e7ff-25a8-4fc4-9f10-a7bebc2e5085" ginger_software_uiphraseguid="f42cc819-7f8e-4f78-85d5-2cdb3da68894" class="GINGER_SOFTWARE_mark">(</gs>"B<gs id="21072260-9197-40b9-bf24-5817fb4b0751" ginger_software_uiphraseguid="f42cc819-7f8e-4f78-85d5-2cdb3da68894" class="GINGER_SOFTWARE_mark">:</gs>C")
Dim <gs id="ddb26647-c9c5-4520-8503-458380db3fd8" ginger_software_uiphraseguid="40f62bb3-557a-459f-9a02-474224901ebb" class="GINGER_SOFTWARE_mark">currName</gs> As String
Dim <gs id="a5d5dd4d-6262-49f0-ba4c-cd69b5e177e2" ginger_software_uiphraseguid="6b25f504-4ab7-4295-9eb9-68d02b830905" class="GINGER_SOFTWARE_mark">cellNum</gs> As Variant
Dim wss As Worksheet: Set <gs id="a5a017f4-1990-4c57-8b7c-f86d5d97a484" ginger_software_uiphraseguid="4bf819b5-02bf-4264-9722-e41fb48ccc8d" class="GINGER_SOFTWARE_mark">wss</gs> = Sheets<gs id="1f534bca-7ec1-4958-9235-90b519099e60" ginger_software_uiphraseguid="4bf819b5-02bf-4264-9722-e41fb48ccc8d" class="GINGER_SOFTWARE_mark">(</gs>"Account Discounts Raw")
Dim TotSales As String
<gs id="c3c1c8bb-0ca2-4ef1-8225-2e6175875b20" ginger_software_uiphraseguid="934ebed9-f503-4cee-87ef-e80798fbbf6c" class="GINGER_SOFTWARE_mark">TotSales</gs> = Application.WorksheetFunction.Sum<gs id="cae9b523-f532-4005-ac0c-b489e8427089" ginger_software_uiphraseguid="934ebed9-f503-4cee-87ef-e80798fbbf6c" class="GINGER_SOFTWARE_mark">(</gs>Sheets<gs id="a4f3ccb9-32db-42db-9d4f-51ccfca734e8" ginger_software_uiphraseguid="934ebed9-f503-4cee-87ef-e80798fbbf6c" class="GINGER_SOFTWARE_mark">(</gs>"Account Discounts Raw"), "M<gs id="f57c541e-1e65-4ce2-80a6-edebe91c98ae" ginger_software_uiphraseguid="934ebed9-f503-4cee-87ef-e80798fbbf6c" class="GINGER_SOFTWARE_mark">:</gs>M")
'<gs id="0b253c73-bf41-4819-a55b-269c630c9b1f" ginger_software_uiphraseguid="48e07d2e-b8e0-4488-bd75-5f7aa513fec5" class="GINGER_SOFTWARE_mark"><gs id="0ecb511b-4f89-42b0-9fac-f602c903dd25" ginger_software_uiphraseguid="cf472096-940a-4251-a915-ce9e1c130497" class="GINGER_SOFTWARE_mark">within</gs></gs> a loop
<gs id="f127f914-5e71-4598-afb7-b30a6d6cc284" ginger_software_uiphraseguid="c30cd374-dc1d-4abb-b936-74a9c5469663" class="GINGER_SOFTWARE_mark"><gs id="30d3f2b9-687b-4bbe-aa02-f587d7b35393" ginger_software_uiphraseguid="33b3f9a8-aff0-43cb-843a-b9ef060e0ebd" class="GINGER_SOFTWARE_mark">currName</gs></gs> = Listbox1.Value
<gs id="b3dcc8fe-6c95-4a8f-8ffe-12098d04d945" ginger_software_uiphraseguid="863ac4c8-ba44-4a4e-9e45-0651787be438" class="GINGER_SOFTWARE_mark"><gs id="9dfd464d-15ad-458e-8df4-e6883ba67efb" ginger_software_uiphraseguid="6acb7e76-719e-4f9b-9caa-8946c95b6500" class="GINGER_SOFTWARE_mark">cellNum</gs></gs> = Application<gs id="d5038416-bde4-4758-af36-a9685b300bf8" ginger_software_uiphraseguid="6acb7e76-719e-4f9b-9caa-8946c95b6500" class="GINGER_SOFTWARE_mark">.</gs>VLookup<gs id="47e0fcf0-af6e-413b-b6df-ccb01a674e2d" ginger_software_uiphraseguid="863ac4c8-ba44-4a4e-9e45-0651787be438" class="GINGER_SOFTWARE_mark"><gs id="49aeb27e-9ac2-4913-8aa7-a5da646660e2" ginger_software_uiphraseguid="6acb7e76-719e-4f9b-9caa-8946c95b6500" class="GINGER_SOFTWARE_mark">(</gs></gs><gs id="9f08b752-7a10-4e11-81f1-68d7d88b0bb9" ginger_software_uiphraseguid="863ac4c8-ba44-4a4e-9e45-0651787be438" class="GINGER_SOFTWARE_mark"><gs id="dd8c8668-3824-47d1-91e7-df73a23f36bb" ginger_software_uiphraseguid="6acb7e76-719e-4f9b-9caa-8946c95b6500" class="GINGER_SOFTWARE_mark">currName</gs></gs>, <gs id="1d75a7cb-b38c-4e43-8cd1-df35d7a265d4" ginger_software_uiphraseguid="863ac4c8-ba44-4a4e-9e45-0651787be438" class="GINGER_SOFTWARE_mark"><gs id="6d712ae6-799f-4502-9ee3-711880717c68" ginger_software_uiphraseguid="6acb7e76-719e-4f9b-9caa-8946c95b6500" class="GINGER_SOFTWARE_mark">rngLook</gs></gs>, 2, True)
If IsError<gs id="d81c0ee6-e80f-4531-9933-a631771df40b" ginger_software_uiphraseguid="c6ac245d-4603-49e9-91b1-8d79561fa4df" class="GINGER_SOFTWARE_mark"><gs id="05bcb7ad-ec10-4e44-a6e5-313ba186a20f" ginger_software_uiphraseguid="20a595ad-0e07-4504-9ce2-c9a148eaa3d2" class="GINGER_SOFTWARE_mark">(</gs></gs><gs id="73425144-b78a-4eb6-a89e-67aad81f456f" ginger_software_uiphraseguid="c6ac245d-4603-49e9-91b1-8d79561fa4df" class="GINGER_SOFTWARE_mark"><gs id="ca6fc4e6-dc1c-466d-8eae-3d498ea25693" ginger_software_uiphraseguid="20a595ad-0e07-4504-9ce2-c9a148eaa3d2" class="GINGER_SOFTWARE_mark">cellNum</gs></gs>) Then
MsgBox "no match"
Else
TextBox1.Value = <gs id="221465c7-819a-4e1b-9df4-8d8778dff742" ginger_software_uiphraseguid="f5d6d6eb-ffd6-485f-a5d1-fd8a665f72e0" class="GINGER_SOFTWARE_mark"><gs id="f4b9f6b6-f317-4c3a-bc85-e74502b94f6d" ginger_software_uiphraseguid="2834b02e-a797-46f5-8afd-0e66522933dd" class="GINGER_SOFTWARE_mark">cellNum</gs></gs>
TextBox2.Value = TotSales
TextBox3.Value =
End If
End Sub
Last edited: