LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
RPH
 
Posts: n/a
Default Using a worksheet name from a range


I've put together a VBA worksheet function that has a range (called
TABLE) passed as one of the parameters.
That range is then entered into an array using loops. I've got this to
work OK if the range data is in the same sheet as I'm using the
function.
Say I'm in Sheet1 of my workbook and the data for TABLE is on Sheet2
I'd like to be able to input
=TEST('Sheet2'!A1:F10)
VBA doesnt seem to like this
I got round it by adding the parameter SN to allow the range data to be
on a different sheet. That has to be manually input in inverted commas
right now.
So my function now looks like:-

Function Test(SN As String, Table As Range)

Dim zarray() As Single '
Dim norows As Integer ' number of rows in the array
Dim nocols As Integer ' and the number of columns
Dim Row As Integer ' Will be the first row of the range
Dim Col As Integer ' will be the first column of the range

' Establish the number of rows and columns in the range "Table"
norows = Table.Rows.Count
nocols = Table.Columns.Count

ReDim zarray(norows, nocols) As Single


Row = Table.Row - 1
Col = Table.Column - 1

For i = 1 To norows
For j = 1 To nocols
zarray(i, j) = Sheets(SN).Cells(i + Row, j + Col)
Next j
Next i


Is there any way I can isolate the worksheet name from the Range
parameter so that I can drop the SN parameter?


Best regards

RPH


--
RPH
 
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
How do I reduce the range of a saved worksheet? John Britten Excel Discussion (Misc queries) 3 September 4th 08 09:46 AM
subtotal a range of cells on a different worksheet cheryl Excel Worksheet Functions 0 November 2nd 05 08:37 PM
Macro to print a selected range, not entire worksheet James C Excel Discussion (Misc queries) 3 October 19th 05 10:12 PM
can bin range for histograms be on a different worksheet? onereallyfrustratedcamper Excel Discussion (Misc queries) 1 May 20th 05 07:08 AM
limit worksheet view to specified cell range Mike Setting up and Configuration of Excel 2 December 16th 04 11:13 PM


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