GeorgeDoors
New Member
- Joined
- Apr 22, 2014
- Messages
- 7
This is the code i currently have;
Sub Renewals()
' Renewals Macro
' To add special offers for drivers
' Keyboard Shortcut: Ctrl+Shift+R
Dim FullForm As String
Dim SpecialOffer1 As String
Dim SpecialOffer2 As String
Dim SpecialOffer3 As String
Dim SpecialOffer4 As String
FullForm = "X1_X2_X3_X4()"
SpecialOffer1 = "=IFERROR(Index('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$D$2:$D$235,"
SpecialOffer2 = "SMALL(IF(VLOOKUP($A2,'P:\Salary Exchange\Renewals\Special Offer Data\[Customer List.xlsx]Sheet2'!$A$1:$B$39,2,0)='P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2:$A$235,"
SpecialOffer3 = "ROW('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2:$A$235)-ROW('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2)+1),"
SpecialOffer4 = "COLUMN('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!A1))),"")"
Columns("W:AG").Select
Selection.NumberFormat = "General"
Range("W2").FormulaArray = FullForm
Range("W2").Replace What:="X1_", Replacement:=SpecialOffer1
Range("W2").Replace What:="X2_", Replacement:=SpecialOffer2
Range("W2").Replace What:="X3_", Replacement:=SpecialOffer3
Range("W2").Replace What:="X4()", Replacement:=SpecialOffer4
Range("W2").Select
but when this is run the result is;
X1_SMALL(IF(VLOOKUP($A2,'P:\Salary Exchange\Renewals\Special Offer Data\[Customer List.xlsx]Sheet2'!$A$1:$B$39,2,0)='P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2:$A$235,ROW('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2:$A$235)-ROW('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2)+1),COLUMN('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!A1))),")
If i take the "=" out of the formula, the full statement is entered but without the equals meaning the formula does not work.
Please help
Sub Renewals()
' Renewals Macro
' To add special offers for drivers
' Keyboard Shortcut: Ctrl+Shift+R
Dim FullForm As String
Dim SpecialOffer1 As String
Dim SpecialOffer2 As String
Dim SpecialOffer3 As String
Dim SpecialOffer4 As String
FullForm = "X1_X2_X3_X4()"
SpecialOffer1 = "=IFERROR(Index('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$D$2:$D$235,"
SpecialOffer2 = "SMALL(IF(VLOOKUP($A2,'P:\Salary Exchange\Renewals\Special Offer Data\[Customer List.xlsx]Sheet2'!$A$1:$B$39,2,0)='P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2:$A$235,"
SpecialOffer3 = "ROW('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2:$A$235)-ROW('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2)+1),"
SpecialOffer4 = "COLUMN('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!A1))),"")"
Columns("W:AG").Select
Selection.NumberFormat = "General"
Range("W2").FormulaArray = FullForm
Range("W2").Replace What:="X1_", Replacement:=SpecialOffer1
Range("W2").Replace What:="X2_", Replacement:=SpecialOffer2
Range("W2").Replace What:="X3_", Replacement:=SpecialOffer3
Range("W2").Replace What:="X4()", Replacement:=SpecialOffer4
Range("W2").Select
but when this is run the result is;
X1_SMALL(IF(VLOOKUP($A2,'P:\Salary Exchange\Renewals\Special Offer Data\[Customer List.xlsx]Sheet2'!$A$1:$B$39,2,0)='P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2:$A$235,ROW('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2:$A$235)-ROW('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!$A$2)+1),COLUMN('P:\Salary Exchange\Renewals\Special Offer Data\[DP 01 Special Offers.xlsx]Sheet1'!A1))),")
If i take the "=" out of the formula, the full statement is entered but without the equals meaning the formula does not work.
Please help