Could someone help me with this problem, please? I’ve written the following code, but XL is not my strong point, loops are one of my weakest points and it’s neither of these that are causing the problem (so far)!
Could someone tell me how to phrase the line that names the range so that the currently selected range is given the name “day” plus the current value of the variable dayNo? The phraseology below (“referstolocal=dayeach”) is obviously incorrect, but I haven’t been able to come up with anything else!
Sub FindFeb01() Dim dayNo As Integer, dayEach As Range dayNo = 1 Set dayEach = Sheets("Feb").Range("a1:b1") For dayNo = 1 To 31 Cells.Find(What:=dayNo, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, _ SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate dayEach = ActiveCell.Offset(1, 0).Range("A1:C3").Select ActiveWorkbook.Names.Add Name:="day" + dayNo, referstolocal=dayEach dayNo = dayNo + 1 Next End Sub
Any help would be gratefully appreciated (not to mention helping reduce my headache)!