Right, with the help of rondebruin, I have made a start. But still need help fine tunning it.
Need to change the search criteria? Need to search for more values, but cant seem to get it to work.
Also it searches for blank cells at the moment, how do I stop this? And it only searches one sheet? Cant seem to amend this for multiple sheets.
Someone Please help! My Vba is rubbish, but im really trying on this one
See code so far:
Sub Mark_cells_in_column()
Dim FirstAddress As String
Dim MyArr As Variant
Dim Rng As Range
Dim I As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
MyArr = Array(Range("A1").Value, Range("A2").Value)
With Sheets("Sheet2").Range("A:A")
.Offset(0, 1).ClearContents
For I = LBound(MyArr) To UBound(MyArr)
Set Rng = .Find(What:=MyArr(I), _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
FirstAddress = Rng.Address
Do
Rng.Offset(0, 1).Value = Range("B1").Value
Rng.Offset(0, 2).Value = Range("C1").Value
Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address <> FirstAddress
End If
Next I
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
This was posted in one of my previous posts, but no luck so far. If you look at my previous post you can see an explanation of what I need it to do. Thanks
Option Explicit Sub Mark_Cells_In_Column() Dim FirstAddress As String, I As Long Dim MyArr As Variant, Rng As Range, Sh As Worksheet
Sheets("Sheet1").Select With Application .ScreenUpdating = False .EnableEvents = False End With MyArr = Array(Range("A1").Value, Range("A2").Value) For Each Sh In ThisWorkbook.Worksheets If Sh.Name <> "Sheet1" Then With Sh.Range("A:A") .Offset(0, 1).ClearContents For I = LBound(MyArr) To UBound(MyArr) Set Rng = .Find(What:=MyArr(I), After:=.Cells(.Cells.Count), _ LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False) If Not Rng Is Nothing Then FirstAddress = Rng.Address Do Rng.Offset(0, 1).Value = Range("B1").Value 'B1<=|' Rng.Offset(0, 2).Value = Range("C1").Value 'C1<=|' Set Rng = .FindNext(Rng) Loop While Not Rng Is Nothing And Rng.Address <> FirstAddress End If Next I End With End If Next Sh With Application .ScreenUpdating = True .EnableEvents = True End With End Sub
Hi, thanks, this seems to work great for multiple sheets. Is there a way to prevent it from searching if the cell is blank. Eventually I plan on having approximatelly 20 cells for search. eg MyArr=A1,A2,A3.........A20, so if cells A1 to A5 contain a value but A6 to A20 dont, then only want it to find the cells that are populated. At the moment if I have a value in A1 and nothing in A2 then it trys to add the values from B1 and C1 to the right of all the blank cells in column A on every worksheet (currently 250).
Thanks again.
Bookmarks