Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel macro - VlookUp

Status
Not open for further replies.

ItIsHardToProgram

Technical User
Mar 28, 2006
946
CA
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
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 sorry, had the following Row at the end of the if.

Round(TempVal,3)

"Knowing that you know is the greatest sign of stupidity, knowing that you are ignorant is the best proof of intelligence.
 





Please post VBA Code questions in Forum707.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thank you, sorry for this mispost.

"Knowing that you know is the greatest sign of stupidity, knowing that you are ignorant is the best proof of intelligence.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top