G'day,
I have a sheet which calculates backpay figures for employees. It is initially entered in through a userform, where hourly rates, hours, penalty rates and all other payroll data needed for this purpose is copied.
Anyway, here is part of my code, where I insert a worksheet formula into a cell:
This code ends up being:
Now, the VLOOKUP ("X10" in this case) is the code for the pay scale; however, Excel reads this as a cell reference instead of text.
If I manually place the X10 within inverted commas (i.e. VLOOKUP("X10"...), the formual works.
"Why not just copy the formula result instead of the whole calculation?" I hear you say? Well, we are audited annually by the State Government, and our auditors need to be able to both verify our calculations and be able to re-produce them themselves. (I also have a boss who doubts modern technology and wants to see for himself how and why the figures are what they are!) It would be a whole lot easier if I did not need to input worksheet formulae, but that is not an option.
I have found a work-around, by removing the X from the pay rate; however, is there a way to place the inverted commas within vba? (Or, Is there a way to copy the TextBox value of txtRate4 to be read by Excel as text?)
Thanks,
Mitch
I have a sheet which calculates backpay figures for employees. It is initially entered in through a userform, where hourly rates, hours, penalty rates and all other payroll data needed for this purpose is copied.
Anyway, here is part of my code, where I insert a worksheet formula into a cell:
Code:
Cells(intRowNum2 + 2, intColNum).Value = "=ROUND((VLOOKUP(" & txtRate1 & _
",Rates!A:E,5,FALSE)*" & lbxr1 & "*" & txtOrdHrs1.Value & _
")+(VLOOKUP(" & txtRate2 & ",Rates!A:E,5,FALSE)*" & lbxr2 & "*" & _
txtOrdHrs2.Value & ")+(VLOOKUP(" & txtRate3 & ",Rates!A:E,5,FALSE)*" & _
lbxr3 & "*" & txtOrdHrs3.Value & ")+VLOOKUP(" & txtRate4 _
& ",Rates!A:E,5,FALSE)*" & lbxr4 & "*" & txtOrdHrs4 & ")+VLOOKUP(" _
& txtRate5 & ",Rates!A:E,5,FALSE)*" & lbxr5 & "*" & txtOrdHrs5 & "),2)"
Code:
=ROUND((VLOOKUP(X10,Rates!A:E,5,FALSE)*1*2)+(VLOOKUP(X10,Rates!A:E,5,FALSE)*1*2)+(VLOOKUP(X10,Rates!A:E,5,FALSE)*1*2)+(VLOOKUP(X10,Rates!A:E,5,FALSE)*1*2)+(VLOOKUP(X10,Rates!A:E,5,FALSE)*1*2),2)
If I manually place the X10 within inverted commas (i.e. VLOOKUP("X10"...), the formual works.
"Why not just copy the formula result instead of the whole calculation?" I hear you say? Well, we are audited annually by the State Government, and our auditors need to be able to both verify our calculations and be able to re-produce them themselves. (I also have a boss who doubts modern technology and wants to see for himself how and why the figures are what they are!) It would be a whole lot easier if I did not need to input worksheet formulae, but that is not an option.
I have found a work-around, by removing the X from the pay rate; however, is there a way to place the inverted commas within vba? (Or, Is there a way to copy the TextBox value of txtRate4 to be read by Excel as text?)
Thanks,
Mitch