ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   view one worksheet from within another workbook (https://www.excelbanter.com/excel-programming/406751-view-one-worksheet-within-another-workbook.html)

Wendy

view one worksheet from within another workbook
 
Hi

Is there anyway I can view the contents of one worksheet of one workbook in
a seperate worksheet in a different workbook.

Thanks

Wendy



michael.beckinsale

view one worksheet from within another workbook
 
Hi Wendy,

I suspect that this relates to your earlier post and that what you
really want to do is to prompt the user to select a row / record to
import from a 'source' workbook into the 'active' workbook.

The only way l can think of achieving this is to use the 'Window'
'Arrange' options, perhaps say placing the 'active' workbook on the
left and the 'source' workbook on the right with the window sized
smaller. This would achieve the visual impact required and allow the
row / record selection in the 'source' workbook.

Whilst writing l am thinking perhaps using the 'Window' 'Arrange'
'Cascade' option and resizing the 'source' window smaller may be a
visually better option. The 'source' window could open in the middle
of the 'active' window following a prompt to select the row / record.

If l am wrong in my original assumption and you only want to take a
'snapshot' of a particular sheet or sheet range look at the 'camera'
function. This will not provide any interactivity.

HTH

Regards

Michael


[email protected]

view one worksheet from within another workbook
 
Hi
From earlier post you wanted to view the data in a workbook called
Post.xls.
The code below assumes post is in D:\Temp and has a worksheet on it
called Data. Change these as required. Attach the
DisplayIt macro to a button in your other workbook. Put the dispayIt
macro and the function below into a code module.
The Post.xls can be open or closed.
Is this what you want to see?

Sub DisplayIt()
Dim PostWorkbook As Workbook
If IsFileOpen("Post.xls") Then
Workbooks("Post").Worksheets("Data").Activate
Else
Set PostWorkbook = Workbooks.Open(filename:="D:\Temp\Post.xls")
ActiveWorkbook.Worksheets("Data").Activate
End If
ThisWorkbook.Activate
Windows.CompareSideBySideWith "post"
End Sub

Function IsFileOpen(filename As String)
Dim filenum As Integer, errnum As Integer
Err.Clear
On Error Resume Next ' Turn error checking off.
filenum = FreeFile() ' Get a free file number.
' Attempt to open the file and lock it.
Open filename For Input Lock Read As #filenum
Close filenum ' Close the file.
errnum = Err ' Save the error number that occurred.
On Error GoTo 0 ' Turn error checking back on.

' Check to see which error occurred.
Select Case errnum
' No error occurred.
' File is NOT already open by another user.
Case 0
IsFileOpen = False
' Error number for "Permission Denied."
' File is already opened by another user.
Case 70
IsFileOpen = True
' Another error occurred.
Case Else
IsFileOpen = False
End Select
End Function


regards
Paul

On Feb 27, 10:44*am, "Wendy" wrote:
Hi

Is there anyway I can view the contents of one worksheet of one workbook in
a seperate worksheet in a different workbook.

Thanks

Wendy



Michael Beckinsale

view one worksheet from within another workbook
 

"michael.beckinsale" wrote in message
...
Hi Wendy,

I suspect that this relates to your earlier post and that what you
really want to do is to prompt the user to select a row / record to
import from a 'source' workbook into the 'active' workbook.

The only way l can think of achieving this is to use the 'Window'
'Arrange' options, perhaps say placing the 'active' workbook on the
left and the 'source' workbook on the right with the window sized
smaller. This would achieve the visual impact required and allow the
row / record selection in the 'source' workbook.

Whilst writing l am thinking perhaps using the 'Window' 'Arrange'
'Cascade' option and resizing the 'source' window smaller may be a
visually better option. The 'source' window could open in the middle
of the 'active' window following a prompt to select the row / record.

If l am wrong in my original assumption and you only want to take a
'snapshot' of a particular sheet or sheet range look at the 'camera'
function. This will not provide any interactivity.

HTH

Regards

Michael




michael.beckinsale

view one worksheet from within another workbook
 
Hi Paul,

It seems we were both thinking along the same lines!

Regards

Michael


Wendy

view one worksheet from within another workbook
 
Hi

Thanks for this, I'm thinking more along the lines of showing the data in
text box, list box or listview rather than displaying the whole
spreadsheet. I only need to see data in columns A,B & C.

Wendy

wrote in message
...
Hi
From earlier post you wanted to view the data in a workbook called
Post.xls.
The code below assumes post is in D:\Temp and has a worksheet on it
called Data. Change these as required. Attach the
DisplayIt macro to a button in your other workbook. Put the dispayIt
macro and the function below into a code module.
The Post.xls can be open or closed.
Is this what you want to see?

Sub DisplayIt()
Dim PostWorkbook As Workbook
If IsFileOpen("Post.xls") Then
Workbooks("Post").Worksheets("Data").Activate
Else
Set PostWorkbook = Workbooks.Open(filename:="D:\Temp\Post.xls")
ActiveWorkbook.Worksheets("Data").Activate
End If
ThisWorkbook.Activate
Windows.CompareSideBySideWith "post"
End Sub

Function IsFileOpen(filename As String)
Dim filenum As Integer, errnum As Integer
Err.Clear
On Error Resume Next ' Turn error checking off.
filenum = FreeFile() ' Get a free file number.
' Attempt to open the file and lock it.
Open filename For Input Lock Read As #filenum
Close filenum ' Close the file.
errnum = Err ' Save the error number that occurred.
On Error GoTo 0 ' Turn error checking back on.

' Check to see which error occurred.
Select Case errnum
' No error occurred.
' File is NOT already open by another user.
Case 0
IsFileOpen = False
' Error number for "Permission Denied."
' File is already opened by another user.
Case 70
IsFileOpen = True
' Another error occurred.
Case Else
IsFileOpen = False
End Select
End Function


regards
Paul

On Feb 27, 10:44 am, "Wendy" wrote:
Hi

Is there anyway I can view the contents of one worksheet of one workbook
in
a seperate worksheet in a different workbook.

Thanks

Wendy




michael.beckinsale

view one worksheet from within another workbook
 
Hi Wendy,

If you want to use the control box 'ListBox' form then simply apply
something like this to its properties:

ListFillRange: '[post]Data'!$A$1:$C$3
ColumnCount: 3

This will display the contents of all 3 columns in a tabular format.

Apply other properties / code as required.

Regards

Michael

[email protected]

view one worksheet from within another workbook
 
Hi Wendy
Try to say what it is you really want, as I suggested in your earlier
posts.
regards
Paul

On Feb 27, 12:52*pm, "Wendy" wrote:
Hi

Thanks for this, I'm thinking more along the lines of showing the data in
text box, list box or *listview rather than displaying the whole
spreadsheet. *I only need to see data *in columns A,B & C.

Wendy

wrote in message

...
Hi
From earlier post you wanted to view the data in a workbook called
Post.xls.
The code below assumes post is in D:\Temp and has a worksheet on it
called Data. Change these as required. Attach the
DisplayIt macro to a button in your other workbook. Put the dispayIt
macro and the function below into a code module.
The Post.xls can be open or closed.
Is this what you want to see?

Sub DisplayIt()
Dim PostWorkbook As Workbook
* *If IsFileOpen("Post.xls") Then
* * Workbooks("Post").Worksheets("Data").Activate
* *Else
* * Set PostWorkbook = Workbooks.Open(filename:="D:\Temp\Post.xls")
* * ActiveWorkbook.Worksheets("Data").Activate
* *End If
* * ThisWorkbook.Activate
* * Windows.CompareSideBySideWith "post"
End Sub

Function IsFileOpen(filename As String)
* * Dim filenum As Integer, errnum As Integer
* * Err.Clear
* * On Error Resume Next * ' Turn error checking off.
* * filenum = FreeFile() * ' Get a free file number.
* * ' Attempt to open the file and lock it.
* * Open filename For Input Lock Read As #filenum
* * Close filenum * * * * *' Close the file.
* * errnum = Err * * * * * ' Save the error number that occurred.
* * On Error GoTo 0 * * * *' Turn error checking back on.

* * ' Check to see which error occurred.
* * Select Case errnum
* * * * ' No error occurred.
* * * * ' File is NOT already open by another user.
* * * * Case 0
* * * * * * IsFileOpen = False
* * * * ' Error number for "Permission Denied."
* * * * ' File is already opened by another user.
* * * * Case 70
* * * * * * IsFileOpen = True
* * * * ' Another error occurred.
* * * * Case Else
* * * * * * IsFileOpen = False
* * End Select
End Function

regards
Paul

On Feb 27, 10:44 am, "Wendy" wrote:



Hi


Is there anyway I can view the contents of one worksheet of one workbook
in
a seperate worksheet in a different workbook.


Thanks


Wendy- Hide quoted text -


- Show quoted text -




All times are GMT +1. The time now is 05:23 PM.

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