I am putting formulas in a worksheet which is dynamic meaning data for row and column keeps changing and also the position for column headers also keeps changing. I need to find the last row and last col and place 4 columns at the end and put formulas autofilled to last row. I have the header names which I find in the row first and then convert column number to letter. Now I need to place formulas in column based on these new column letters. I have the following code so far. The Vlookup formula is not working.
Dim eNB as Integer
Dim eNBCol as string
Dim eUTRAN as integer
Dim eUTRANCol as string
With Rows(1)
Set d = .Find("ENODEB")
If Not d Is Nothing Then
eNB = d.Column
End If
Set d = .Find("EUTRANCELL")
If Not d Is Nothing Then
eUTRAN = d.Column
End If
End With
eNBCol = ConvertToLetter(eNB)
eUTRANCol = ConvertToLetter(eUTRAN)
wb("wsTrungReport").Cells(1, lstCol + 1).Value = "Cell-ID"
wb("wsTrungReport").Cells(2, lstCol + 1).Formula = "=" & eNB_Col & 2 & "&" & eUTRANCol & 2
wb("wsTrungReport").Cells(1, lstCol + 2).Value = "Manager"
'Vlookup formulas is not working
wb("wsTrungReport").Cells(2, lstCol + 2).Formula = "=Vlookup(" & eUTRANCol & 2 ",SiteDatabase!I:W,15,0)"
"=Vlookup(" & eUTRANCol & 2 & ",SiteDatabase!I:W,15,0)". It also might be better in this case to fill the block of cells in the column all at once.