Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing a range to a function


I'm trying to add charts programmatically by passing the cell range to a
function. Simple version is like this:

Application.Run _
"myPlotFunct", ActiveSheet, Range(Cells(1,1),Cells(5,5))

I have no problem with the first chart but the 2nd, 3rd,... don't like
this command because the ActiveSheet is a chart after each run through
the function. My solution is:

set mySheet = ActiveSheet
Application.Run _
"myPlotFunct", ActiveSheet, Range(Cells(1,1),Cells(5,5))
mySheet.Activate

This works fine but is awfully clunky. How do I pass the range over to
the function without having to switch pages in between? I've tried:

set mySheet = ActiveSheet
Application.Run _
"myPlotFunct", mySheet(Range(Cells(1,1),Cells(5,5)))

and I've also tried:

set mySheet = ActiveSheet
Application.Run _
"myPlotFunct", mySheet.Range(Cells(1,1),Cells(5,5)))

No luck so far.


--
Isabelle
------------------------------------------------------------------------
Isabelle's Profile: http://www.excelforum.com/member.php...o&userid=30752
View this thread: http://www.excelforum.com/showthread...hreadid=504203

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Passing a range to a function

Try

Application.Run _
"myPlotFunct", mySheet.Range(mySheet.Cells(1,1),mySheet.Cells(5,5 )))


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Isabelle" wrote in
message ...

I'm trying to add charts programmatically by passing the cell range to a
function. Simple version is like this:

Application.Run _
"myPlotFunct", ActiveSheet, Range(Cells(1,1),Cells(5,5))

I have no problem with the first chart but the 2nd, 3rd,... don't like
this command because the ActiveSheet is a chart after each run through
the function. My solution is:

set mySheet = ActiveSheet
Application.Run _
"myPlotFunct", ActiveSheet, Range(Cells(1,1),Cells(5,5))
mySheet.Activate

This works fine but is awfully clunky. How do I pass the range over to
the function without having to switch pages in between? I've tried:

set mySheet = ActiveSheet
Application.Run _
"myPlotFunct", mySheet(Range(Cells(1,1),Cells(5,5)))

and I've also tried:

set mySheet = ActiveSheet
Application.Run _
"myPlotFunct", mySheet.Range(Cells(1,1),Cells(5,5)))

No luck so far.


--
Isabelle
------------------------------------------------------------------------
Isabelle's Profile:

http://www.excelforum.com/member.php...o&userid=30752
View this thread: http://www.excelforum.com/showthread...hreadid=504203



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
Passing a range to a user defined function Gary Nelson Excel Discussion (Misc queries) 1 July 19th 07 04:22 PM
Passing a range into a VBA function Floyd[_2_] Excel Programming 4 February 10th 05 01:29 AM
Passing range as an argument in a function Hari[_3_] Excel Programming 1 June 15th 04 02:41 AM
Passing a Range to a Function Problem Rocky McKinley Excel Programming 4 January 7th 04 02:00 AM
Passing an unkown range to a function Newbie3333 Excel Programming 3 December 5th 03 02:14 AM


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