ItIsHardToProgram
Technical User
Hello everyone,
I am currently working on a excel macro for my company and I just want to validate that this macro will work before implementing it since the files we are using are rather large.
This is what the macro should do:
Go look in a file, using an account number, at a specific column for a long.
Put the specific value in a temporary variable
Test if everything was performed correctly if not, send a msg indicating where the error was found.
Round the value.
Put the value in the active cell.
The macro I came with that I call YlookUp is the following.
Private sub YlookUp(GLaccount as intger, location as string, ActColumn as integer, TempVal as long) return TempVal
TempVal = VlookU(Glaccount,location,ActColumn,0)
If TempVal = null then
TempVal as string = ERROR
Msgbox("You have encountered an error with value " + 'GLaccount' + " " + location)
End if
Round(TempVal,3)
End Sub.
My problem is the following. I am not sure how to put the information in the excel cell so that the cell = TempVal.
I was thinking that something like this might work but im prety certain it wont.
[Highlight]=YlookUp(Bud09!$A18,'S:\Comptabilite\RPR - Budget 2009\FI\[11050_VillaStGeorges_B09.xls]B09 12 mois'!$A:$O,5)[/highlight]
I am very happy for any opinion on how I perform this "lookup" and on how to optimize it. If there is an error or if it is perfect (wich is impossible) Please still state a response. I will not implement this without a second opinion.
Thank you very much for your time.
"Knowing that you know is the greatest sign of stupidity, knowing that you are ignorant is the best proof of intelligence.
I am currently working on a excel macro for my company and I just want to validate that this macro will work before implementing it since the files we are using are rather large.
This is what the macro should do:
Go look in a file, using an account number, at a specific column for a long.
Put the specific value in a temporary variable
Test if everything was performed correctly if not, send a msg indicating where the error was found.
Round the value.
Put the value in the active cell.
The macro I came with that I call YlookUp is the following.
Private sub YlookUp(GLaccount as intger, location as string, ActColumn as integer, TempVal as long) return TempVal
TempVal = VlookU(Glaccount,location,ActColumn,0)
If TempVal = null then
TempVal as string = ERROR
Msgbox("You have encountered an error with value " + 'GLaccount' + " " + location)
End if
Round(TempVal,3)
End Sub.
My problem is the following. I am not sure how to put the information in the excel cell so that the cell = TempVal.
I was thinking that something like this might work but im prety certain it wont.
[Highlight]=YlookUp(Bud09!$A18,'S:\Comptabilite\RPR - Budget 2009\FI\[11050_VillaStGeorges_B09.xls]B09 12 mois'!$A:$O,5)[/highlight]
I am very happy for any opinion on how I perform this "lookup" and on how to optimize it. If there is an error or if it is perfect (wich is impossible) Please still state a response. I will not implement this without a second opinion.
Thank you very much for your time.
"Knowing that you know is the greatest sign of stupidity, knowing that you are ignorant is the best proof of intelligence.