Hello Experts
I have a macro which identify last used row and then find specific text (Sun) and then Offset columns and put another text over there (Day)
Query: there is loop used and while searching text in specific column and putting value in offsetting column Macro search the phrase multiple time ie number of times last used is. e.g. Last used row is 50th then search function gives results in specific cell but 50 times it runs the loop And if last used row is above 1000 then it will take too much time
I want that loop should run only once till last used row
Regards,
Please help macro is as follows
------------------------------------
Sub Searching()
Dim i As Long
Dim FRow As Range
Dim LastRow As Long
LastRow = Range("I" & Rows.Count).End(xlUp).Row
Do
For i = LastRow To 1 Step -1
Set FRow = Cells.Find(What:="Day", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
FRow.Activate
Selection.Offset(0, -8).Select
Selection.Value = "Sun"
Selection.Offset(1, 0).Select
Next i
Loop Until LastRow
End Sub
I have a macro which identify last used row and then find specific text (Sun) and then Offset columns and put another text over there (Day)
Query: there is loop used and while searching text in specific column and putting value in offsetting column Macro search the phrase multiple time ie number of times last used is. e.g. Last used row is 50th then search function gives results in specific cell but 50 times it runs the loop And if last used row is above 1000 then it will take too much time
I want that loop should run only once till last used row
Regards,
Please help macro is as follows
------------------------------------
Sub Searching()
Dim i As Long
Dim FRow As Range
Dim LastRow As Long
LastRow = Range("I" & Rows.Count).End(xlUp).Row
Do
For i = LastRow To 1 Step -1
Set FRow = Cells.Find(What:="Day", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
FRow.Activate
Selection.Offset(0, -8).Select
Selection.Value = "Sun"
Selection.Offset(1, 0).Select
Next i
Loop Until LastRow
End Sub