View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
OssieMac OssieMac is offline
external usenet poster
 
Posts: 2,510
Default How to refer to a workbook?

Hi Faraz,

Hope you can follow my example. I tried to break it up so it will make more
sense.

Sub SpclMcro()
Dim SrcWS As Worksheet
Dim DstWS As Worksheet
Dim SrcWB As Workbook
Dim Dst As Workbook
Dim Src As Range
Dim Dest As Range

Set Src = Application.InputBox("WHAT?", , , , , , , 8)
'Set Dest = Application.InputBox("WHERE?", , , , , , , 8)

'Set Src = ActiveSheet.Range("A1:A10")

'Worksheet of range Src
Set SrcWS = Src.Parent
MsgBox SrcWS.Name

'Workbook of worksheet SrcWS
Set SrcWB = SrcWS.Parent
MsgBox SrcWB.Name

'Therefore in one line the workbook of range Src
Set SrcWB = Src.Parent.Parent
MsgBox SrcWB.Name

End Sub


--
Regards,

OssieMac