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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LookUp formulas to bring two cells together 1

Status
Not open for further replies.

BaldyMcFatFat

Technical User
Dec 5, 2007
23
US
I am having an issue trying to come up with a way to pull values from two seperate cells in a workbook and convere them into one cell on a seperate workbook.

Easiest way to explain it: I run a report for work that gives me hard values and is set-up perfectly to use an hLookUp. It basically gives me a table with multiple lines of data and I need to move that data to a seperate workbook but have it in one cell as a phrase instead of just numbers. I basically need it to show up as the following phrase: "X out of Y were correct."

As you can probably imagine, X equals the first line of data under the LookUp_Value and Y equals the second line under the LookUp_Value.

I am new to the VBA world and pretty much have been thrown in with training or people to ask questions. I have never done programming in the past and am trying to learn as I go along. I have searched every resource I know of and haven't found anything on this particular question.

If anyone has any help on this, that would be greatly appreciated. Right now, I would even take helpful sarcasm.
 
Hi Baldy,

Are you sure you're doing this with vba? I ask because HLookup is a worksheet function (though you can call it from vba).

Whichever the answer is, the vba or worksheet offset function allows you to point to a row and/or column that is a specified distance from your 'current' cell.

There are various other possible approaches in vba. See also 'cells' in Excel's vba Help file for some pointers.

Cheers

[MS MVP - Word]
 



As macropod stated, this is not a VBA question. If you have a question regarding how to accomplish this in Excel, please post in Forum68.

Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
I know this is a worksheet function and thoroughly know how to use it within a worksheet itself. I was wondering if there is a way to utilize this function in vba code to input a phrase where two sections of the code are from a seperate workbook altogether. I am looking to utilize vba to create a macro that inputs a phrase such as "X out of Y are correct." "X" and "Y" are the variables that are needed to be pulled from a seperate workbook. I know how to use the LookUp formula and all, but was not sure if it can be inputted into a macro using vba to assign values to the "X" and "Y" variables. I hope this clarifies what I am trying to accomplish. If this is something I still need to post to another forum, please let me know and I appologize for wasting viewing space.
 
I was wondering if there is a way to utilize this function in vba code
Well, yes - with Application.WorksheetFunction.Lookup, or whichever other variant of the Lookup function (eg HLookup, VLookup) you want to use.

Cheers

[MS MVP - Word]
 
Although I'm still not sure why you need VBA.

=concatenate(hlookup(), " out of ",hlookup(), " are correct.")

 
Turn on your macro recorder (Tools > Macros > Record New Macro) and do whatever it is you want to do.

Observe the code that was generated ([Alt]+[F11 will get you to the VBEditor).

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
Thank you all for the information. Thank you mintjulep for that advise. As skipvought stated earlier it was an equation question but I didn't know. So thank you to all. And please forgive my ignorance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top