SlightlyClueless
New Member
- Joined
- Dec 10, 2018
- Messages
- 15
- Office Version
- 365
- Platform
- Windows
Hi All,
I am looking for a little assistance with the VBA code in the workbook I have been working on. There is a userform with dependent dropdowns that pulls their values from "Master Sheet" in the workbook. The drop downs are functioning fine. However I have two roadblocks that I have now been able to get past. The first, The dropdowns allow the selection of "Category, Make, Model, and Add To". In the Master Sheet, "Category, Make, Model" Run from Columns A:C. Columns D:G have the equipment's, "Weight, Length, Width, Depth" information. I have not been able to have the information from columns A:F be copied based off the model selection. I have been trying have it paste in a test are for functionality with no luck. However once that would be functioning the "Add To" combo box selection in the user form would specify the range in the ECA worksheet to place that data. In the combo box selection, selecting "Keep" would place that information in range S3:Y16, "Remove" would be range S18:Y32, and "Final" would be range S35:Y47. Since numerous pieces of equipment would be added into each section when adding a piece of equipment it would place that entry in the next empty row of that range.
Any help or direction would be appreciated.
Dependent Drop Down Code
Dynamic Dropdown Module Code
ECA Sheet
MASTER SHEET
I am looking for a little assistance with the VBA code in the workbook I have been working on. There is a userform with dependent dropdowns that pulls their values from "Master Sheet" in the workbook. The drop downs are functioning fine. However I have two roadblocks that I have now been able to get past. The first, The dropdowns allow the selection of "Category, Make, Model, and Add To". In the Master Sheet, "Category, Make, Model" Run from Columns A:C. Columns D:G have the equipment's, "Weight, Length, Width, Depth" information. I have not been able to have the information from columns A:F be copied based off the model selection. I have been trying have it paste in a test are for functionality with no luck. However once that would be functioning the "Add To" combo box selection in the user form would specify the range in the ECA worksheet to place that data. In the combo box selection, selecting "Keep" would place that information in range S3:Y16, "Remove" would be range S18:Y32, and "Final" would be range S35:Y47. Since numerous pieces of equipment would be added into each section when adding a piece of equipment it would place that entry in the next empty row of that range.
Any help or direction would be appreciated.
Dependent Drop Down Code
VBA Code:
Private Sub cmbAddTo_Change()
End Sub
Private Sub cmdCancel_Click()
frmUser.Hide
End Sub
Private Sub UserForm_Initialize()
cmbCategory.RowSource = DynamicList(1, Null, 1, "Master Sheet", "Drop Down")
End Sub
Private Sub cmbCategory_Change()
cmbMake.RowSource = DynamicList(1, cmbCategory.Value, 2, "Master Sheet", "Drop Down")
End Sub
Private Sub cmbMake_Change()
cmbModel.RowSource = DynamicList(2, cmbMake.Value, 3, "Master Sheet", "Drop Down")
End Sub
Dynamic Dropdown Module Code
VBA Code:
'Parameters - FilterColumn: Where we need to apply filter, FilterText : filter text value, DropDownColumn:Which column is for drop-down
Function DynamicList(FilterColumn As Integer, FilterText As Variant, DropDownColumn As Integer, MasterSheet As String, DropDownSheet As String) As String
'If FilterText is blank then exit from function
If FilterText = "" Then Exit Function
'On Error GoTo err_handler
Dim shMaster As Worksheet
Dim shDropDown As Worksheet
Dim iMasterLastRow As Double
Dim iMasterLastColumn As Double
Dim iDropDownLastRow As Integer
Set shMaster = ThisWorkbook.Sheets(MasterSheet)
Set shDropDown = ThisWorkbook.Sheets(DropDownSheet)
'removing existing filters, if any
If shMaster.AutoFilterMode Then shMaster.AutoFilterMode = False
'Applying filter in Master Data Sheet
With shMaster
iMasterLastRow = .Range("A" & .Rows.Count).End(xlUp).Row 'identify the last row number in Master Sheet
iMasterLastColumn = .Cells(1, .Columns.Count).End(xlToLeft).Column 'identify the last column number in Master Sheet
'Applying Filter in Master Sheet
.Range(.Cells(1, 1), .Cells(iMasterLastRow, iMasterLastColumn)).AutoFilter Field:=FilterColumn, Criteria1:=FilterText
End With
'Removing the existing data from the drop-down column number
With shDropDown
.Range(.Cells(1, DropDownColumn), .Cells(Rows.Count, iMasterLastColumn)).ClearContents
End With
'Copying the filter drop down column basis on filter value and paste in Drop Down sheet
With shMaster
.Range(.Cells(1, DropDownColumn), .Cells(iMasterLastRow, DropDownColumn)).SpecialCells(xlCellTypeVisible).Copy shDropDown.Cells(1, DropDownColumn)
.AutoFilterMode = False 'Removing filters
End With
With shDropDown
'Removing duplicates from all the columns
.Columns(DropDownColumn).RemoveDuplicates Columns:=1, Header:=xlYes
'identifying last row number in drop-down sheet
iDropDownLastRow = .Cells(Rows.Count, DropDownColumn).End(xlUp).Row
'code to exclude column headers if no value in dropdown column in drop down sheet
iDropDownLastRow = IIf(iDropDownLastRow < 2, 2, iDropDownLastRow) 'code to exclude header if only header there
'Assigning the range in function name to return the value
DynamicList = "'Drop Down'!" & .Range(.Cells(2, DropDownColumn), .Cells(iDropDownLastRow, DropDownColumn)).Address
End With
Exit Function
err_handler:
MsgBox Err.Description
End Function
ECA Sheet
Rent Sheet.xlsm | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
P | Q | R | S | T | U | V | W | X | Y | Z | AA | |||
1 | ||||||||||||||
2 | Existing To Remain | Proposed or Existing Centerline | Qty | Equip Type | Equip Make | Equip Model | Equip Weight (lbs) | Equip Dimensions (Inches) | Equip Surface Sq In | Line Total Sq In | ||||
3 | 123 | 0 | #VALUE! | |||||||||||
4 | 0 | 0 | ||||||||||||
5 | 0 | 0 | ||||||||||||
6 | 0 | 0 | ||||||||||||
7 | 0 | 0 | ||||||||||||
8 | 0 | 0 | ||||||||||||
9 | 0 | 0 | ||||||||||||
10 | 0 | 0 | ||||||||||||
11 | 0 | 0 | ||||||||||||
12 | 0 | 0 | ||||||||||||
13 | 0 | 0 | ||||||||||||
14 | 0 | 0 | ||||||||||||
15 | 0 | 0 | ||||||||||||
16 | 0 | 0 | ||||||||||||
17 | ||||||||||||||
18 | Removing | Proposed or Existing Centerline | Qty | Equip Type | Equip Make | Equip Model | Equip Weight (lbs) | Equip Dimensions (Inches) | Equip Surface Sq In | Line Total Sq In | ||||
19 | 0 | 0 | ||||||||||||
20 | 0 | 0 | ||||||||||||
21 | 0 | 0 | ||||||||||||
22 | 0 | 0 | ||||||||||||
23 | 0 | 0 | ||||||||||||
24 | 0 | 0 | ||||||||||||
25 | 0 | 0 | ||||||||||||
26 | 0 | 0 | ||||||||||||
27 | 0 | 0 | ||||||||||||
28 | 0 | 0 | ||||||||||||
29 | 0 | 0 | ||||||||||||
30 | 0 | 0 | ||||||||||||
31 | 0 | 0 | ||||||||||||
32 | 0 | 0 | ||||||||||||
33 | ||||||||||||||
34 | Final | Proposed or Existing Centerline | Qty | Equip Type | Equip Make | Equip Model | Equip Weight (lbs) | Equip Dimensions (Inches) | Equip Surface Sq In | Line Total Sq In | ||||
35 | 0 | 0 | ||||||||||||
36 | 0 | 0 | ||||||||||||
37 | 0 | 0 | ||||||||||||
38 | 0 | 0 | ||||||||||||
39 | 0 | 0 | ||||||||||||
40 | 0 | 0 | ||||||||||||
41 | 0 | 0 | ||||||||||||
42 | 0 | 0 | ||||||||||||
43 | 0 | 0 | ||||||||||||
44 | 0 | 0 | ||||||||||||
45 | 0 | 0 | ||||||||||||
46 | 0 | 0 | ||||||||||||
47 | 0 | 0 | ||||||||||||
ECA |
Cell Formulas | ||
---|---|---|
Range | Formula | |
Z3:Z16,Z35:Z47,Z19:Z32 | Z3 | =IFERROR(SUM(LARGE(W3:Y3,1)*LARGE(W3:Y3,2)),0) |
AA3:AA16,AA35:AA47,AA19:AA32 | AA3 | =R3*Z3 |
MASTER SHEET
Rent Sheet.xlsm | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | |||
1 | Category | Make | Model | Weight | (Height) | (Width) | (Depth) | Add To | |||
2 | Antenna | AEHC | Active Antenna Massive MIMO | 10 | 1 | 2 | 3 | Keep | |||
3 | Antenna | Commscope | FFVV-65C-R3-V1 | 20 | 2 | 3 | 4 | Remove | |||
4 | Antenna | Nokia | AEHC-Massive MIMO | 30 | 3 | 4 | 5 | Final | |||
5 | Other | Nokia | HCS 2.0 Junction Box Pendants | 40 | 4 | 5 | 6 | ||||
6 | RRU | Nokia | AHFIG | 50 | 5 | 6 | 7 | ||||
7 | RRU | Nokia | AHLOA | 60 | 6 | 7 | 8 | ||||
8 | RRU | Nokia | NWS | 70 | 7 | 8 | 9 | ||||
9 | Surge | HCS | HCS 2.0 Breakout Feature (part one) | 90 | 9 | 10 | 11 | ||||
10 | |||||||||||
Master Sheet |