|
-
Aug 5th, 2005, 04:36 PM
#1
Thread Starter
Member
Simple question from VBA noobie..
Hi,
for some reason I can not do this because I am new to VBA. How can I get a chart reference be made available in a userform?
I know module's is where you would want to declare global variables, but I still have a problem there.
In my spreadsheet:
VB Code:
Private sub transferChart()
Sheets("Sheet1").ChartObjects("Chart 1").Activate
Call toModule(ActiveChart)
End Sub
In Module:
VB Code:
Public Function toModule(ByVal mychart As Chart)
chartA = mychart
End Function
'userform would call this function to get the chart reference from spreadsheet
Public Function returnChart() As Chart
returnChart = chartA
End Function
this way seems kind of tedious. Is there another way, becuase this one isn't working.
-
Aug 5th, 2005, 04:38 PM
#2
Thread Starter
Member
Re: Simple question from VBA noobie..
btw, my chartA variable is a declared global variable in Module1.
I also have 'Set chartA = mychart' instead of 'chartA = mychart'
thanks!!
-
Aug 8th, 2005, 04:14 AM
#3
Re: Simple question from VBA noobie..
Code:
Private sub transferChart()
toModule Sheets("Sheet1").ChartObjects("Chart 1")
End Sub
Once you set it in the module, if you declare the variable to be public, you can just use that variable name from anycode in the forms modules or other modules directly. No need for a return function.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|