Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Private Sub Running Other Private Sub Inadvertently

I have an object-heavy spreadsheet with alot of code supporting those objects on a single sheet module. For some reason when on of the routines is executed, it jumps to the first routine in the module, runs it and then returns back to continue the first. The point at which it jumps is shown below. The sub it jumps to is "


' Save the request with a new name.
ActiveWorkbook.SaveAs Filename:= _
"C:\temp\PTR" & piRequestNo & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
'The jump occurs here.
ActiveWorkbook.SendMail , Subject:="Pass Thru Request", ReturnReceipt:=True


Jumps to here
Private Sub cbCat1_Change()

Is it possible to have too much code on a sheet module? I'm thinking I need to move some of this code to a separate, non-sheet module.

Any help would be tremendously appreciated.

Ross
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Private Sub Running Other Private Sub Inadvertently

I think I've read posts that describe this.

I think that this is the situation (untested, though).

cbCat1 is a combobox from the Control toolbox toolbar on the worksheet?

And cbCat1 uses a .listfillrange?

And that .listfillrange is on the same worksheet as the combobox?

If yes, either fill the combobox via .additem or move the list to a different
sheet.

Post back with your results, please.


Ross Culver wrote:

I have an object-heavy spreadsheet with alot of code supporting those objects
on a single sheet module. For some reason when on of the routines is
executed, it jumps to the first routine in the module, runs it and then
returns back to continue the first. The point at which it jumps is shown
below. The sub it jumps to is "


' Save the request with a new name.
ActiveWorkbook.SaveAs Filename:= _
"C:\temp\PTR" & piRequestNo & ".xls", _
FileFormat:=xlNormal, Password:="",
WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
'The jump occurs here.
ActiveWorkbook.SendMail ,
Subject:="Pass Thru Request", ReturnReceipt:=True

Jumps to here
Private Sub cbCat1_Change()

Is it possible to have too much code on a sheet module? I'm thinking I need
to move some of this code to a separate, non-sheet module.

Any help would be tremendously appreciated.

Ross


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Private Sub Running Other Private Sub Inadvertently

Dave, thanks for the info; however, it doesn't look like this is the answer.

The problem lies with the file save as code:

ActiveWorkbook.SaveAs Filename:="C:\temp\PTR" & piRequestNo & ".xls",
FileFormat:=xlNormal, Password:="", WriteResPassword:="",
ReadOnlyRecommended:=False, CreateBackup:=False

When I comment out this, the execution does not jump to the other routines.
Also, it doesn't jump to a specific sub, it runs through all of them!

I tried moving it to a public sub in a separate module, but that made no
difference.

Ross


"Dave Peterson" wrote in message
...
I think I've read posts that describe this.

I think that this is the situation (untested, though).

cbCat1 is a combobox from the Control toolbox toolbar on the worksheet?

And cbCat1 uses a .listfillrange?

And that .listfillrange is on the same worksheet as the combobox?

If yes, either fill the combobox via .additem or move the list to a
different
sheet.

Post back with your results, please.


Ross Culver wrote:

I have an object-heavy spreadsheet with alot of code supporting those
objects
on a single sheet module. For some reason when on of the routines is
executed, it jumps to the first routine in the module, runs it and then
returns back to continue the first. The point at which it jumps is shown
below. The sub it jumps to is "


' Save the request with a new name.
ActiveWorkbook.SaveAs Filename:= _
"C:\temp\PTR" & piRequestNo & ".xls", _
FileFormat:=xlNormal, Password:="",
WriteResPassword:="", _
ReadOnlyRecommended:=False,
CreateBackup:=False
'The jump occurs here.
ActiveWorkbook.SendMail
,
Subject:="Pass Thru Request", ReturnReceipt:=True

Jumps to here
Private Sub cbCat1_Change()

Is it possible to have too much code on a sheet module? I'm thinking I
need
to move some of this code to a separate, non-sheet module.

Any help would be tremendously appreciated.

Ross


--

Dave Peterson



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
Private Sub() - Sub() CousinExcel Excel Discussion (Misc queries) 2 January 18th 10 01:39 PM
Private sub Mark New Users to Excel 3 April 6th 05 03:36 PM
Private Sub Ronbo Excel Programming 11 January 13th 05 08:25 PM
Private Sub Workbook_Open() not running on open Tim[_39_] Excel Programming 0 August 30th 04 09:11 PM
Problem with private sub Conrado Capistrano Excel Programming 2 October 4th 03 08:35 AM


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