Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm trying to insert a Vlookup into a cell based on variables that are collceted via a user form. Only problem is, for the "Else" part of the the below "If" statement I get a "Run-time error '1004': Application-defined or object-defined error". I think it's becuase it doesn't like the concatenation of the FundCode and Series variables, but I can't work out how to fix it. The first part of the "If" statement works when the Fundcode variable is passed as a string, but in the latter case when Fundcode is passed as a cell address it doesn't work. Can anyone give me any help or advice? Thanks in advance, Scott ----------------- Sub InsertFundPrice(FundCode As Variant, Series As String, Pricedate As Date) Dim PriceMonth, PriceYear As String PriceMonth = Left(MonthName(Month(Pricedate)), 3) PriceYear = Right(Pricedate, 4) If Len(FundCode) <= 2 Then ActiveCell.FormulaR1C1 = _ "=VLOOKUP(""" & FundCode & Series & """,'J:\RESTRICT \Performance\Bulletin\Fund Prices\" & PriceYear & "\" & PriceMonth & "\ [fund prices 01" & PriceMonth & PriceYear & ".xls]Summary'! R2C4:R2000C5,2,FALSE)" Else VTarget = FundCode & " & " & Series ActiveCell.FormulaR1C1 = _ "=VLOOKUP(" & VTarget & ",'J:\RESTRICT\Performance\Bulletin \Fund Prices\" & PriceYear & "\" & PriceMonth & "\[fund prices 01" & PriceMonth & PriceYear & ".xls]Summary'!R2C4:R2000C5,2,FALSE)" End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Inserting rows while keeping cell contents the same | Excel Discussion (Misc queries) | |||
Concatinating text plus cell containing date | Excel Worksheet Functions | |||
Taking contents of a cell an inserting them into a phrase. | Excel Discussion (Misc queries) | |||
Problems using a variable as a Table_Array in VLOOKUP | Excel Worksheet Functions | |||
Inserting Cell Contents into a header | Excel Programming |