VBA Copy from depend drop downs

SlightlyClueless

New Member
Joined
Dec 10, 2018
Messages
15
Office Version
  1. 365
Platform
  1. 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

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
PQRSTUVWXYZAA
1
2Existing To RemainProposed or Existing CenterlineQtyEquip TypeEquip MakeEquip ModelEquip Weight (lbs)Equip Dimensions (Inches)Equip Surface Sq InLine Total Sq In
31230#VALUE!
400
500
600
700
800
900
1000
1100
1200
1300
1400
1500
1600
17
18RemovingProposed or Existing CenterlineQtyEquip TypeEquip MakeEquip ModelEquip Weight (lbs)Equip Dimensions (Inches)Equip Surface Sq InLine Total Sq In
1900
2000
2100
2200
2300
2400
2500
2600
2700
2800
2900
3000
3100
3200
33
34FinalProposed or Existing CenterlineQtyEquip TypeEquip MakeEquip ModelEquip Weight (lbs)Equip Dimensions (Inches)Equip Surface Sq InLine Total Sq In
3500
3600
3700
3800
3900
4000
4100
4200
4300
4400
4500
4600
4700
ECA
Cell Formulas
RangeFormula
Z3:Z16,Z35:Z47,Z19:Z32Z3=IFERROR(SUM(LARGE(W3:Y3,1)*LARGE(W3:Y3,2)),0)
AA3:AA16,AA35:AA47,AA19:AA32AA3=R3*Z3



MASTER SHEET

Rent Sheet.xlsm
ABCDEFGHI
1Category MakeModelWeight(Height)(Width)(Depth)Add To
2AntennaAEHCActive Antenna Massive MIMO10123Keep
3AntennaCommscopeFFVV-65C-R3-V120234Remove
4AntennaNokiaAEHC-Massive MIMO30345Final
5OtherNokiaHCS 2.0 Junction Box Pendants40456
6RRUNokiaAHFIG50567
7RRUNokiaAHLOA60678
8RRUNokiaNWS70789
9SurgeHCSHCS 2.0 Breakout Feature (part one)9091011
10
Master Sheet
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top