Can a workbook variable be set by clicking the workbook?

D

Dave Peterson

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
 
B

Bob Phillips

I think it would be better to explain what you are trying to achieve, we
might be able to help then.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top