LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #17   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Sheet Offset - is this possible? - Problem

Thank you so much JMB. Have a safe flight.

"JMB" wrote:

Good luck. Now that I've had some shuteye myself (and thinking more
clearly), if you want the function to show as a formula in Excel, do as Dick
suggested. If you want to do strictly in VBA use:

MsgBox Worksheets(ActiveSheet.Index + 1).Range("A1")

This would give you the flexibility to use a point of reference other than
the Activesheet (Say Sheet3.Index+1 -note I'm using the codename for the
sheet). The SHEETOFFSET function as I've modified assumes the activesheet is
the point of reference. Mr. Walkenbach probably did not design the function
to be called from either a worksheet or VBA because with VBA there's an
easier way.

I've got to catch a plane (literally) -so don't think me rude if I don't
post back today.



"MichaelC" wrote:

JMB, Vasant, Steve and Dick - thank you all very much. I will implement all
your valuable advice tomorrow after a little shuteye. I'd have given up a
long time ago were it not for your thoughtful patience.

"JMB" wrote:

Note in my previous post that I made changes to the function code. Copy and
paste into your module.


"MichaelC" wrote:

Thanks for staying with me, JMB.
I'm not using quotes. I'm doing something else wrong.
I copied and pasted the function into a fresh worksheet under VBA Project /
Excel objects / ThisWorkbook.
Then I wrote:
Sub Test()
ActiveCell = SHEETOFFSET(1, A1)
End Sub

When I ran the Sub Test I got Run-time error 424 - Object required.

What did I do different from you when you successfully tested it?
I appreciate your patience.


"JMB" wrote:

I copied the code in exactly as you posted it and no problems.
Unfortunately, I'm unable to duplicate your error, even with option explicit.

For the range reference, are you using quotes or not?

=SHEETOFFSET(3,"A1")

or

=SHEETOFFSET(3,A1)

It has to be entered w/o quotes.

If you had to declare the argument variable types,

Function SHEETOFFSET(offset as integer, Ref as range) as variant


"MichaelC" wrote:

The function formula from J-Walk is:
Function SHEETOFFSET(offset, Ref)
' Returns cell contents at Ref, in sheet offset
Application.Volatile
With Application.Caller.Parent
SHEETOFFSET = .Parent.Sheets(.Index + offset) _
.Range(Ref.Address).Value
End With
End Function

I cannot get this to work, probably due to some basic misconception I have.
I get Run Time Error 424 ( text following a dot is not recognized as object)

Is this something to do with Option Explicit? If that means I have to
declare my variables, what needs to be done?
I apologise for what I know are elementary questions.


"MichaelC" wrote:

Thank you both, gentlemen. The J-Walk reference is exactly where I had
originally seen the reference. Still strange that VBA help, nor for that
matter John Walkenbach's excellent Power Programming book seems to make any
reference to this extremely useful tool!

"JMB" wrote:

Try this link

http://j-walk.com/ss/excel/tips/tip63.htm

"MichaelC" wrote:

Is there such an animal as Sheet Offset (# of Sheets).
I once made a note when I saw it but now can find no references to it
anywhere.
Thanks in advance for all advice

 
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
formula to look up ref in one sheet and offset in another vickya Excel Worksheet Functions 1 May 25th 10 05:59 PM
Copy link to offset sheet SNACK D Excel Worksheet Functions 5 December 14th 07 01:38 AM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
Offset in another sheet wienmichael Excel Discussion (Misc queries) 2 November 2nd 06 09:21 PM
Using offset more than once on the same sheet Pat Excel Worksheet Functions 1 September 8th 05 11:34 PM


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

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"