Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Referring to a worsheet in another workbook

I am attempting to get this code to work. The issue I am having is that the
worksheet named Socal Work Order is in another workbook. HOw do I refer to
it? Is there a way I can do it without using the workbook name, provided
both workbooks are open? I am using Office 2003 Pro SP2.

Dim Inrng As Range
Dim ORng As Range
Dim inWs As Worksheet
Dim outWs As Worksheet
Dim iLastRow As Long

Set inWs = ActiveSheet
Set outWs = Worksheets("SoCal Work Order")
Set ORng = outWs.Cells(outWs.Cells(92, 1).End(xlUp).Row + 1, "A")

TIA

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Referring to a worsheet in another workbook

Sub GetItHereForFree()
On Error GoTo Err_Handler
Dim Inrng As Range
Dim ORng As Range
Dim inWs As Worksheet
Dim outWs As Worksheet
Dim WB As Excel.Workbook

On Error Resume Next
For Each WB In Excel.Workbooks
Set outWs = WB.Worksheets("SoCal Work Order")
If Err.Number = 0 Then Exit For
Err.Clear
Next
On Error GoTo Err_Handler

If Not outWs Is Nothing Then
Set ORng = outWs.Cells(92, 1).End(xlUp)(2, 1)
MsgBox ORng.Address(external:=True)
Else
MsgBox "Oops"
Exit Sub
End If

Set inWs = ActiveSheet
'something else
Exit Sub

Err_Handler:
'handle error
End Sub
------------

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Roundy"

wrote in message
I am attempting to get this code to work. The issue I am having is that the
worksheet named Socal Work Order is in another workbook. HOw do I refer to
it? Is there a way I can do it without using the workbook name, provided
both workbooks are open? I am using Office 2003 Pro SP2.

Dim Inrng As Range
Dim ORng As Range
Dim inWs As Worksheet
Dim outWs As Worksheet
Dim iLastRow As Long

Set inWs = ActiveSheet
Set outWs = Worksheets("SoCal Work Order")
Set ORng = outWs.Cells(outWs.Cells(92, 1).End(xlUp).Row + 1, "A")

TIA

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
referring to previous worksheet in workbook Freida Excel Worksheet Functions 9 September 29th 09 09:33 PM
Excel Worsheet/Workbook formula links CrossCutter Excel Discussion (Misc queries) 1 December 9th 08 01:18 AM
Formula referring to a dynamic range in a different workbook mr tom Excel Worksheet Functions 6 March 29th 07 08:56 AM
Worsheet and workbook tiler New Users to Excel 1 April 19th 06 01:22 PM
Referring to function in another workbook psp Excel Worksheet Functions 1 August 31st 05 10:32 PM


All times are GMT +1. The time now is 07:39 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"