Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How to go to next workbook?

I want to copy to the next workbook,
but some code I found doesn't even start to work.

At http://www.cpearson.com/excel/sheetref.htm
it talks about worksheets but I get stuck at:
Application.Volatile True
v = Application.Caller.Parent.Index
which gives an 'object reqd' msg.

also
i = Application.Caller.Parent.Parent.Worksheets.Count
fails the same way.

I just did the latter with a copy/paste,
so it's not a typo problem.

I'm calling the macro from the spreadsheet with alt-F8.

Hope you can help,
Peter.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default How to go to next workbook?

his example is probably coded to be called from a formula in a cell
THEN the application caller will identify the cell it was called from.
and the application.caller.parent will id the sheet it was called from.

=sheetposition() typed in a cell will have the functon work,
but it cannot be called from a macro.





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Peter Chatterton wrote :

I want to copy to the next workbook,
but some code I found doesn't even start to work.

At http://www.cpearson.com/excel/sheetref.htm
it talks about worksheets but I get stuck at:
Application.Volatile True
v = Application.Caller.Parent.Index
which gives an 'object reqd' msg.

also
i = Application.Caller.Parent.Parent.Worksheets.Count
fails the same way.

I just did the latter with a copy/paste,
so it's not a typo problem.

I'm calling the macro from the spreadsheet with alt-F8.

Hope you can help,
Peter.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default How to go to next workbook?

Peter

The code on that particular site is all Function code for User Defined
Functions.

These do not run as macros.

They act the same as regulae worksheet Functions in a cell.

You would copy the entire Function to a general module in your workbook then
call it from a cell.

e.g. copy the code below to a general module

Function SheetsCount() As Integer
Application.Volatile True
SheetsCount = Application.Caller.Parent.Parent.Worksheets.Count
End Function

Then in a worksheet cell enter

=SheetsCount() to return the number of sheets in the workbook.

Functions cannot copy things to other cells or sheets. They just return data
to the cell they are entered in.

Read Chip's page again and you will see he gives good examples of usage for
each of the UDF's on that page.

Gord Dibben Excel MVP


On Thu, 18 Nov 2004 17:58:28 -0500, "Peter Chatterton"
wrote:

I want to copy to the next workbook,
but some code I found doesn't even start to work.

At http://www.cpearson.com/excel/sheetref.htm
it talks about worksheets but I get stuck at:
Application.Volatile True
v = Application.Caller.Parent.Index
which gives an 'object reqd' msg.

also
i = Application.Caller.Parent.Parent.Worksheets.Count
fails the same way.

I just did the latter with a copy/paste,
so it's not a typo problem.

I'm calling the macro from the spreadsheet with alt-F8.

Hope you can help,
Peter.


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
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Excel Programming 2 April 3rd 04 06:18 AM
Excel Gurus = want a macro in 1 workbook to get info from another workbook = Read please harry Excel Programming 5 December 20th 03 03:26 AM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


All times are GMT +1. The time now is 01:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"