I have a macro code I need help to modify to my needs.
This is what it does:
The macro will find data that will be entered in a cell in a worksheet. In other words the data entered will be changeable.
The macro searches the array for the data, and if present in the array it goes to the cell containing the data and erase it.
Assume the data to be located in the array is in Sheet 1, cell A1 and the array is in sheet 2 cells A1 thru D200.
Type the data into sheet1 cell
A1, then activate the macro and have it locate the matching data in sheet2 cells A1 thru D200, then clear the matching data from cells A1 thru D200.
Here is what I need it to modify to do:
I need to expand the data cell A1 on sheet 1 to A1:A200
Also I need to expand Sheet 2 array for A1 thru cz300 or entire Sheet 2
Here is the code that needs to be modified:
Sub FindIt()
Dim strFindMe As String, rngData As Range
Dim rngFound As Range, firstaddress As String
strFindMe = Worksheets("Sheet1").Range("A1").Value
'the entry To find
With Worksheets("Sheet2")
Set rngData = .Range("A1:D200")
'the range To search
Set rngFound = rngData.Find(strFindMe, LookIn:=xlValues)
If Not rngFound Is Nothing Then
firstaddress = rngFound.Address
Do
rngFound.Clear
'clear data In the matching cell
Set rngFound = rngData.FindNext(rngFound)
If rngFound Is Nothing Then Exit Do
Loop While rngFound.Address <> firstaddress
End If
End With
End Sub
your help would be greatly appreciated.
Thanks.
This is what it does:
The macro will find data that will be entered in a cell in a worksheet. In other words the data entered will be changeable.
The macro searches the array for the data, and if present in the array it goes to the cell containing the data and erase it.
Assume the data to be located in the array is in Sheet 1, cell A1 and the array is in sheet 2 cells A1 thru D200.
Type the data into sheet1 cell
A1, then activate the macro and have it locate the matching data in sheet2 cells A1 thru D200, then clear the matching data from cells A1 thru D200.
Here is what I need it to modify to do:
I need to expand the data cell A1 on sheet 1 to A1:A200
Also I need to expand Sheet 2 array for A1 thru cz300 or entire Sheet 2
Here is the code that needs to be modified:
Sub FindIt()
Dim strFindMe As String, rngData As Range
Dim rngFound As Range, firstaddress As String
strFindMe = Worksheets("Sheet1").Range("A1").Value
'the entry To find
With Worksheets("Sheet2")
Set rngData = .Range("A1:D200")
'the range To search
Set rngFound = rngData.Find(strFindMe, LookIn:=xlValues)
If Not rngFound Is Nothing Then
firstaddress = rngFound.Address
Do
rngFound.Clear
'clear data In the matching cell
Set rngFound = rngData.FindNext(rngFound)
If rngFound Is Nothing Then Exit Do
Loop While rngFound.Address <> firstaddress
End If
End With
End Sub
your help would be greatly appreciated.
Thanks.