ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can a workbook variable be set by clicking the workbook? (https://www.excelbanter.com/excel-programming/315094-can-workbook-variable-set-clicking-workbook.html)

Kobayashi[_43_]

Can a workbook variable be set by clicking the workbook?
 

If so, how? If not, any suggestions?

Many thanks,

Adria

--
Kobayash
-----------------------------------------------------------------------
Kobayashi's Profile: http://www.excelforum.com/member.php...info&userid=87
View this thread: http://www.excelforum.com/showthread.php?threadid=27331


Dave Peterson[_3_]

Can a workbook variable be set by clicking the workbook?
 
Option Explicit
Sub testme()
Dim myRng As Range
Dim wkbk As Workbook

On Error Resume Next
Set myRng = Application.InputBox(prompt:="Click on a cell", Type:=8)
On Error GoTo 0

If myRng Is Nothing Then
Exit Sub
End If

MsgBox myRng.Parent.Name 'worksheet
MsgBox myRng.Parent.Parent.Name 'workbook

'so...
Set wkbk = myRng.Parent.Parent
'....

End Sub



Kobayashi wrote:

If so, how? If not, any suggestions?

Many thanks,

Adrian

--
Kobayashi
------------------------------------------------------------------------
Kobayashi's Profile: http://www.excelforum.com/member.php...nfo&userid=871
View this thread: http://www.excelforum.com/showthread...hreadid=273314


--

Dave Peterson


Bob Phillips[_6_]

Can a workbook variable be set by clicking the workbook?
 
I think it would be better to explain what you are trying to achieve, we
might be able to help then.

--

HTH

RP

"Kobayashi" wrote in message
...

If so, how? If not, any suggestions?

Many thanks,

Adrian


--
Kobayashi
------------------------------------------------------------------------
Kobayashi's Profile:

http://www.excelforum.com/member.php...nfo&userid=871
View this thread: http://www.excelforum.com/showthread...hreadid=273314





All times are GMT +1. The time now is 03:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com