View Single Post
 
Old 05-10-2015, 03:58 PM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 32bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

To find locations of the Transfer Number you might want to use range.find and .findnext
See https://msdn.microsoft.com/en-us/lib.../ff839746.aspx

Here's how it could be used in your Transfer sub
Code:
Sub Transfer()
    
TransferNumber = InputBox(Prompt:="Transfer Number?", Title:="Number?")
With Sheets("Transfer Log").Range("A:A")
    Set fndNum = .Find(TransferNumber, LookIn:=xlValues)
    If Not fndNum Is Nothing Then   '<~~ the transfer number was found
        firstAddress = fndNum.Address
        Do
            With Sheets("Transfer Form")
                'find the row to write to
                writeRow = .Cells(Rows.Count, "A").End(xlUp).Row + 1
                .Cells(writeRow, 1).Resize(1, 4).Value = fndNum.Offset(0, 2).Resize(1, 4).Value
            End With
            Set fndNum = .FindNext(fndNum)
        Loop While Not fndNum Is Nothing And fndNum.Address <> firstAddress
    End If
End With

End Sub
Reply With Quote