I have data coming in from an external source daily. On one sheet I have a list of ticker symbols (sorted alphabetically) with corresponding data continuing in that row.
On another sheet I have the ticker's organized by their corresponding sector, rather than being organized alphabetically.
I'm trying to develop a macro so that the info from the first sheet will automatically paste into the second sheet by recognizing the ticker and pasting in the appropriate row.
Here's the code being used so far but it has not worked the way intended:
Dim LSymbol As String
Dim LRow As Integer
Dim LFound As Boolean
On Error GoTo Err_Execute
'Retrieve symbol value to search for
LSymbol = Sheets("Portfolio Update").Range("B4").Value
Sheets("Test").Select
'Start at row 2
LRow = 2
LFound = False
While LFound = False
'Encountered blank cell in column B, terminate search
If Len(Cells(2, LRow)) = 0 Then
MsgBox "No matching symbol was found."
Exit Sub
'Found match in column b
ElseIf Cells(2, LRow) = LSymbol Then
'Select values to copy from "Portfolio Update" sheet
Sheets("Portfolio Update").Select
Range("B5:V5").Select
Selection.Copy
'Paste onto "Test" sheet
Sheets("Test").Select
Cells(3, LRow).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
LFound = True
MsgBox "The data has been successfully copied."
'Continue searching
Else
LRow = LRow + 1
End If
Wend
On Error GoTo 0
Exit Sub
Err_Execute:
MsgBox "An error occurred."
End Sub
Thanks.