I am stuck,
I am only marginally familiar with arrays and I can not figure out how to deal with the "ByRef argument type mismatch error" the Sub gives because "Area" is a variant not a string
Thanks
Sub Area()
Dim Areas As Variant
Dim Area As Variant
Areas = Array("K2:K", "R2:R", "Y2:Y", "AG2:AG")
For Each Area In Areas
If Not DoIHaveARange("XXX", Area, "Yes") Is Nothing Then 'Code
Next Area
End Sub
Public Function DoIHaveARange(ShtName As String, Rng As String, FindWhat As String) As Range
Dim ws As Worksheet
Dim lRow As Long
Set ws = ThisWorkbook.Sheets(ShtName)
lRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
Set DoIHaveARange = Range(Rng & lRow).Find(What:=FindWhat, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
End Function
Bookmarks