Hi All,
having an issue with my code and hoping someone can help.
I have a workbook that has 2 sheets, 1 is the master data sheet the other is the active sheet "Allowed repair" with 2 buttons, search and clear contents. I have set the command button to execute the following VBA macro in a module but keep getting an error for a not set object.
Originally my code was written on the data sheet and it searches that sheet and exports the output to sheet #2 .
The macro still runs correctly when running from master data sheet but not when the macro is called from the command button on the active sheet.
here is my macro
Sub SearchForString()
Dim LSearchValue As String
Dim RefCount As Integer
LSearchValue = InputBox("Please enter a value to search for.", "Enter value") & "*"
RefCount = Application.WorksheetFunction.CountIf(Sheet1.Range("A:L"), LSearchValue) - 1
Range("A1").Activate
For Counter = 0 To RefCount Step 1
With Columns("A:L").Find(What:=LSearchValue, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
.EntireRow.Copy Worksheets("Allowed repair").Range("A65536").End(xlUp).Offset(1, 0)
.Activate
End With
Next
End Sub
Thank you
having an issue with my code and hoping someone can help.
I have a workbook that has 2 sheets, 1 is the master data sheet the other is the active sheet "Allowed repair" with 2 buttons, search and clear contents. I have set the command button to execute the following VBA macro in a module but keep getting an error for a not set object.
Originally my code was written on the data sheet and it searches that sheet and exports the output to sheet #2 .
The macro still runs correctly when running from master data sheet but not when the macro is called from the command button on the active sheet.
here is my macro
Sub SearchForString()
Dim LSearchValue As String
Dim RefCount As Integer
LSearchValue = InputBox("Please enter a value to search for.", "Enter value") & "*"
RefCount = Application.WorksheetFunction.CountIf(Sheet1.Range("A:L"), LSearchValue) - 1
Range("A1").Activate
For Counter = 0 To RefCount Step 1
With Columns("A:L").Find(What:=LSearchValue, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
.EntireRow.Copy Worksheets("Allowed repair").Range("A65536").End(xlUp).Offset(1, 0)
.Activate
End With
Next
End Sub
Thank you