ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problems calling macros from "ThisWorkbook" (https://www.excelbanter.com/excel-programming/350890-problems-calling-macros-thisworkbook.html)

blesbok

Problems calling macros from "ThisWorkbook"
 

I am trying to call a macro from a sheet using thisworkbook, however,
don't think it allows this. Therefore as a solution I just recopie
the macro that I was using into "thisworkbook". However, th
'Sheets("Charts").ChartObjects("Chart "
r).SeriesCollection(1).XValues = ' command does not seem to b
recognized in this object, so now I am unable to autoupdate the chart
which was the whole reason for this whole process. Any help in eithe
getting that command to work in "thisworkbook" or allowing me to call
macro from a sheet using "thisworkbook" would be greatly appreciated

--
blesbo
-----------------------------------------------------------------------
blesbok's Profile: http://www.excelforum.com/member.php...fo&userid=3063
View this thread: http://www.excelforum.com/showthread.php?threadid=50289


blesbok[_2_]

Problems calling macros from "ThisWorkbook"
 

No one has any ideas?


--
blesbok
------------------------------------------------------------------------
blesbok's Profile: http://www.excelforum.com/member.php...o&userid=30635
View this thread: http://www.excelforum.com/showthread...hreadid=502891


Dave Peterson

Problems calling macros from "ThisWorkbook"
 
I had difficulty understanding the question.

But if the procedure is behind a worksheet, you could use:

Option Explicit
Public Sub mySub()
MsgBox "hi from the sheet"
End Sub

And call it via:
Option Explicit
Private Sub Workbook_Open()
Call Sheet1.mySub
End Sub

If the procedure is in ThisWorkbook:
Option Explicit
Public Sub mySub()
MsgBox "hi from thisworkbook"
End Sub

and called elsewhere (from a sheet or general module):
Option Explicit
Sub other_sub()
Call ThisWorkbook.mySub
End Sub

But I think moving general procedures to General modules is the best/safest bet.





blesbok wrote:

No one has any ideas?

--
blesbok
------------------------------------------------------------------------
blesbok's Profile: http://www.excelforum.com/member.php...o&userid=30635
View this thread: http://www.excelforum.com/showthread...hreadid=502891


--

Dave Peterson


All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com