Link to home
Start Free TrialLog in
Avatar of KP_SoCal
KP_SoCalFlag for United States of America

asked on

Search and Replace VBA in Excel

I'm looking for a block of code that will search row one of "Sheet1" to find a value that is equal to left(Main!B2,3).  One value has been found, I need it to set all number values in that column to ZERO.

So if Main!B2 was "March" and Sheet1!D1 ended up matching left(Main!B2,3), then all values in that column starting in row 2 would be ZERO.

To apply this to the entire column containing data, I probably need to incorporate something like this:
Private Sub AutoFill()
Dim LastRowInA As Long

Dim r As Range
Set r = Range("Match of left(Main!B2")

LastRowInA = Range("A1048576").End(xlUp).Row

r.AutoFill Destination:=Range("Match of left(Main!B2" & LastRowInA)

End Sub

Open in new window

Obviously my code above is wrong, but it should give you an idea of what I'm looking to accomplish.  Thanks for any help!  Also I attached a sample spreadsheet.
Example.xlsx
ASKER CERTIFIED SOLUTION
Avatar of Dave
Dave
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KP_SoCal

ASKER

Perfecto!  Thanks so much and yes, I did attach the wrong sample. LOL

=)