Hello Everyone.
This is my first post so I am not sure how everything works or if my title is correct, please let me know if anything needs changing. Anyway to my problem, I have a database on my second sheet and on the first sheet there is a selection of the important headings from the database.
E.g
sheet 1
A B
9 Report Failure Search Button CheckBox (linked to F9)
10 Author PEH Search Button CheckBox (linked to F10)
11 Search Button
B9 Failure is selected from a drop down menu, if I click the search button then it will search the database for all failure reports. This works fine and will give you a list on sheet 3. This also works if I press the search button for the Author.
My problem is I want to click the search button on row 11 and would like it search for both report and author when they are checked, there are more rows and search buttons which I have not shown. So when I would like it to search for which ever checkBoxes are checked. This is the code I have used, apologies it is a bit messy I am by no means an expert. This shows how it searches for a single variable. If you could please explain how I could make this search for the checked boxes I would be very grateful.
Again I would be greatful for any help.![]()
Dim LSearchRow As Integer Dim LCopyToRow As Integer On Error GoTo Err_Execute Dim start As Integer Dim finish As Integer Dim val1 As String start = 1 finish = 6000 'Start search in row 4 LSearchRow = 2 'Start copying data to row 2 in Sheet2 (row counter variable) LCopyToRow = 3 Application.ScreenUpdating = False 'Unhides all columns from previous searches Sheets("sheet3").Select Columns("S").Select Selection.EntireColumn.Hidden = True Range("A3:AQ6000").Clear 'Assigns Values to variables Sheets("sheet1").Select val1 = Range("B9").Value 'Uses variables to assign data on the database sheet Sheets("sheet2").Select Range("Z1") = val1 While start < finish Sheets("sheet2").Select If Range("I" & CStr(LSearchRow)).Value = Range("Z1") Then 'Select row in Sheet2 to copy Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select Selection.Copy 'Paste row into Sheet3 in next row Sheets("sheet3").Select Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select ActiveSheet.Paste 'Move counter to next row LCopyToRow = LCopyToRow + 1 'Go back to Sheet1 to continue searching Sheets("sheet2").Select End If LSearchRow = LSearchRow + 1 start = start + 1 Wend 'Position on cell A3 Application.CutCopyMode = False Sheets("sheet3").Select Range("A2").Select Application.ScreenUpdating = True MsgBox "To Seach again please go back to the sheet1" Exit Sub Err_Execute: MsgBox "An error occurred." End Sub
Bookmarks