fbpos and fbml are spreadsheets in the active workbook HM. They have the price for the symbol by account#.
phmcpws is a spreadsheet that opens earlier in the code. The symbol headers are in row 3, which are also the variable that I am trying to vlookup in fbpos spreadsheet. The symbol is getting it's value from a different cell.
Dim ticRange As Range, hmRange As Range, hmanRange As Range
Dim ticStr As String, cStr As String
Dim vTic As Variant
Dim lastCol As Integer, tCol As Integer
Set ticRange = phmcpws.Range("E3:N3", "R3:W3") 'symbol range in PH sheet
Set hmRange = fbpos.Range("A:A", "G:I") 'acct# and symbol range in HM sheet
Set hmanRange = hmRange.Find(What:=acctNum, LookIn:=xlValues, LookAt:=xlWhole) 'acct# filter
lastCol = ticRange.Columns.Count
For tCol = 1 To lastCol
ticStr = ticRange.Cells(3, tCol).value
If Not ticStr = "" Then
vTic = Application.VLookup(ticStr, hmanRange, 2, False)
If IsError(vTic) Or IsEmpty(vTic) Then 'error OR empty
Else
cvStr = CStr(vTic)
phmcpws.Cells(4, tCol).value = cvStr
End If
End If
Next tCol

New Topic/Question
Reply



MultiQuote




|