L
Legacy 185734
Guest
Hey All,
I'm normally pretty good with most programming, but I cant seem to figure out what is wrong with my formula in VBA. I've tried a few things/different variations so apologies if the formula is now completely messed up!
So yea, in this case, the formula should look like this:
Now when I debug I can see that the formula is correct in what I want it to look like, but I'm getting an error.
Please note that when entering code, it kept ignoring everything after a "<", so I have replaced "<" with ""LESS THAN"". In the actual code there is a "<" (without quotations).
Hope someone can clear the syntax issue or whatever it is I'm doing wrong.
Cheers.
I'm normally pretty good with most programming, but I cant seem to figure out what is wrong with my formula in VBA. I've tried a few things/different variations so apologies if the formula is now completely messed up!
Code:
Dim columnNumber As Integer
Dim columnNumber1 As Integer
Dim columnNumber2 As Integer
Dim columnLetter As String
Dim columnLetter1 As String
Dim columnLetter2 As String
columnNumber = 33 'AG - Fixed row number for vlookups
columnNumber1 = 33 'AG
columnNumber2 = 18 'R
columnLetter = Left(Cells(1, columnNumber).Address(1, 0), InStr(1, Cells(1, columnNumber).Address(1, 0), "$") - 1)
columnLetter1 = Left(Cells(1, columnNumber1).Address(1, 0), InStr(1, Cells(1, columnNumber1).Address(1, 0), "$") - 1)
columnLetter2 = Left(Cells(1, columnNumber2).Address(1, 0), InStr(1, Cells(1, columnNumber2).Address(1, 0), "$") - 1)
Range(columnLetter1 + "4").Select
ActiveCell.Formula = _
"=IFERROR(IF(" & columnLetter1 + 7 & "/(" & columnLetter1 + 5 & "*oee)"LESS THAN"VLOOKUP(" & columnLetter + 1 & ",LineHours,4,FALSE)*'Look Up'!" & columnLetter2 + 5 & "," & columnLetter1 + 7 & "/(" & columnLetter1 + 5 & "*oee),VLOOKUP(" & columnLetter + 1 & ",LineHours,4,FALSE)*'Look Up'!" & columnLetter2 + 5 & "),"")"
Code:
=IFERROR(IF(AG7/(AG5*oee)"LESS THAN"VLOOKUP(AG1,LineHours,4,FALSE)*'Look Up'!R5,AG7/(AG5*oee),VLOOKUP(AG1,LineHours,4,FALSE)*'Look Up'!R5),"")
Please note that when entering code, it kept ignoring everything after a "<", so I have replaced "<" with ""LESS THAN"". In the actual code there is a "<" (without quotations).
Hope someone can clear the syntax issue or whatever it is I'm doing wrong.
Cheers.