Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Vlookup with mouse over definitions

Paste the following code into the sheet module of report.xls
(right-click the sheet tab and choose view code)
Any existing code in the module should be removed before adding my code.

For it to work, the data.xls workbook must be open.
Right-click a cell in the first 50 rows of column "A" (report.xls workbook)
and the value from the column to the right of the lookup value in the
data.xls workbook (first sheet) is displayed in a fake ToolTip.
Change "50" in the 'Set rngStart' line to the actual number of rows.
There is no error handling in the code.

'--
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _
Cancel As Boolean)
'Jim Cone - Portland, Oregon USA - April 2009
Dim rngStart As Excel.Range
Dim vRngValue As Variant
Dim rngWhat As Excel.Range
Set rngStart = Application.Intersect(Me.Columns(1), Me.Range("1:50"))
If Not Application.Intersect(Target(1), rngStart) Is Nothing Then
Cancel = True
rngStart.Validation.Delete
On Error Resume Next
Set rngWhat = _
Workbooks("data.xls").Worksheets(1) _
.UsedRange.Find(Target(1).Value).Offset(0, 1)
On Error GoTo 0
If Not rngWhat Is Nothing Then
vRngValue = rngWhat.Value
Else
vRngValue = "Not Found"
End If
With Target(1).Validation
.Add Type:=xlValidateCustom, _
AlertStyle:=xlValidAlertInformation, Formula1:=True
.InCellDropdown = True
.InputTitle = vbNullString
.InputMessage = vRngValue
.ShowInput = True
End With
End If
End Sub
--

Jim Cone
Portland, Oregon USA





"Bryand"
wrote in message
I am trying to get a vlookup with mouse-over to work, however I am having
difficulty assigning a Global Variable, and cannot identify what variables to
declare.

My situation:
data.xls - Columns A:B hold the vlookup information
report.xls - is the file I want to apply this macro to, so that when I right
click on a value in Column A it will look into the data.xls file and return
the value in a popup.

I need to define the range variable (I assumed the range variable was the
€śTheCell€ť but I also see €śDataElements€ť and €śLookupRange€ť €“ are these all
variables that need to be defined?) within report.xls. My previous attempt
was:

Sub RVariable()
Dim TheCell As Range
TheCell = A: D
End Sub

I have a feeling I should not be using a sub, as the macro above does not
call to it - I am a novice with VB and usually work backwards from a finished
product so any assistance would be greatly appreciated.

Code taken from previous response:
-snip-

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Name definitions BR Excel Programming 6 January 16th 09 11:31 AM
Global definitions Matthew Balch[_2_] Excel Programming 1 November 3rd 06 01:48 PM
xl* object definitions ?? Bill Case Excel Programming 3 August 31st 06 09:36 PM
Definitions Nick Excel Discussion (Misc queries) 1 July 1st 05 09:25 AM
Operator definitions Niklas[_2_] Excel Programming 2 July 25th 03 01:09 PM


All times are GMT +1. The time now is 04:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"