Hello,
I am a beginner on this forum so feel free to let me know if i am showing any code incorrectly.
So here is my issue. I have a sheet containing rows of different components to a system with different designations (ex. FW-TAT-1). I have another sheet that i use to pull these designations into 6 separate listboxs in a userform. When I click my command button i copy the masterlist to a new sheet and name it through TextBox2. What then happens is the rows that do not contain the correct designation (based on the selection in the listboxs) in column "C" of the new sheet are deleted. This works perfectly for one listbox.
Thanks for the help
logan
I am a beginner on this forum so feel free to let me know if i am showing any code incorrectly.
So here is my issue. I have a sheet containing rows of different components to a system with different designations (ex. FW-TAT-1). I have another sheet that i use to pull these designations into 6 separate listboxs in a userform. When I click my command button i copy the masterlist to a new sheet and name it through TextBox2. What then happens is the rows that do not contain the correct designation (based on the selection in the listboxs) in column "C" of the new sheet are deleted. This works perfectly for one listbox.
What is happening is every row is being deleted off of the new sheet. I want the selections in the listboxs to still show up. These are not multiselect listboxs.Private Sub CommandButton2_Click()
'This copies the Masterlist
Worksheets("Air Handling Unit").Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = TextBox2
Range("C1") = TextBox2
'This is where my problem lies
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Firstrow = ActiveSheet.UsedRange.Cells(1).Row + 5
Lastrow = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row
For Lrow = Lastrow To Firstrow Step -1
If ActiveSheet.Range("C" & Lrow).Value <> ListBox1.Value Then ActiveSheet.Range("C" & Lrow).EntireRow.Delete
If ActiveSheet.Range("C" & Lrow).Value <> ListBox2.Value Then ActiveSheet.Range("C" & Lrow).EntireRow.Delete
If ActiveSheet.Range("C" & Lrow).Value <> ListBox3.Value Then ActiveSheet.Range("C" & Lrow).EntireRow.Delete
If ActiveSheet.Range("C" & Lrow).Value <> ListBox4.Value Then ActiveSheet.Range("C" & Lrow).EntireRow.Delete
If ActiveSheet.Range("C" & Lrow).Value <> ListBox5.Value Then ActiveSheet.Range("C" & Lrow).EntireRow.Delete
If ActiveSheet.Range("C" & Lrow).Value <> ListBox6.Value Then ActiveSheet.Range("C" & Lrow).EntireRow.Delete
End Sub
Thanks for the help
logan