I have a code that's first job is to find "Qty" and "Fty" word in P column. Then it will get the row number of that row. The code was running smoothly. But now when I added a loop the code throws an error. "run time error method find of object range failed" I want that the loop will be get that two row number and a value will be print after the first row till the last row.
Suppose you have input "qty" word in row number 12 and column number P and "fty" word in row number 15 and column number P(Here is to mention that the column number of the input cell will be always in P). The loop's work is to get the value from A13 to A14 and print in the P13 to P14.
Here is my code :
Private Sub Worksheet_Change(ByVal Target As Range) Dim qtyWordFinder As Range Dim qtyWordFinder2 As Range Dim acidWashQty As Integer Dim rw1 As Integer Dim rw2 As Integer Set qtyWordFinder = Range("$P$1:$P$53").Find("Qty", SearchOrder:=xlColumns) Set qtyWordFinder2 = Range("$P$1:$P$53").Find("Fty", SearchOrder:=xlColumns) If qtyWordFinder Is Nothing Then Else rw1 = qtyWordFinder.row End If If qtyWordFinder2 Is Nothing Then Else rw2 = qtyWordFinder2.row End If Dim i As Integer For i = rw1 + 1 To rw2 - 1 Cells(i, 16).Value = Cells(i, 1).Value Next i End Sub