Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ctr ctr is offline
external usenet poster
 
Posts: 1
Default combo box macro runs when using "save as"

I have a spreadsheet used as a form.

There is a combo box on the main page which changes the entries of
other cells
on other sheets dependant on the value chosen in the combo box.

I am using case statements to check the value of the combo box and
then change the values in other cells.

The problem is that when the user uses 'Save As' the combo box_change
macro runs and changes/deletes entries the user may have made
according to the initial rules when the macro first ran.

How do I stop this from happening?
Is there a way of checking if the user has selected 'Save As' and then
preventing the macro from running or is it simpler than this.

Any help much appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default combo box macro runs when using "save as"

One way would be to have a global variable, set that in the BeforeSave
event if SaveAsUI is true, and test that in the combobox macro.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ctr" wrote in message
om...
I have a spreadsheet used as a form.

There is a combo box on the main page which changes the entries of
other cells
on other sheets dependant on the value chosen in the combo box.

I am using case statements to check the value of the combo box and
then change the values in other cells.

The problem is that when the user uses 'Save As' the combo box_change
macro runs and changes/deletes entries the user may have made
according to the initial rules when the macro first ran.

How do I stop this from happening?
Is there a way of checking if the user has selected 'Save As' and then
preventing the macro from running or is it simpler than this.

Any help much appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default combo box macro runs when using "save as"

Makes sense but how do I set a global variable if SaveAsUI is true?
can't seem to get it to work.
Thanks



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default combo box macro runs when using "save as"

Create a Public variable outside of a procedure in a standard code module,
call it say NoCombo and declare as a Boolean.

In the BeforeSave event in ThisWorkbook module

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
NoCombo = Not SaveAsUI
End Sub

and in your combo box macro/event, add something like

If Not NoCombo Then
'your code here
End If

You will also need to work out where in your code NoCombo gets set to False
again.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"James Martin" wrote in message
...
Makes sense but how do I set a global variable if SaveAsUI is true?
can't seem to get it to work.
Thanks



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default combo box macro runs when using "save as"

Got it working now. Thanks very much for your help. Much appreciated.



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 ronhansen Excel Discussion (Misc queries) 1 November 15th 09 09:33 PM
Macro to Insert Current Date into cell - Macro to "Save As" Guy[_2_] Excel Worksheet Functions 4 December 12th 08 08:20 PM
"CELL("FILENAME") NOT UPDATE AFTER "SAVE AS" ACTION yossie6 Excel Discussion (Misc queries) 1 June 16th 08 12:16 PM
"Save" and "Save As" options greyed out - "Save as Webpage" option Bill Excel Discussion (Misc queries) 0 January 16th 07 04:47 PM
Unprotecting 4 sheets before "WorkbookOpen" macro runs kcdonaldson Excel Discussion (Misc queries) 1 December 7th 05 02:21 PM


All times are GMT +1. The time now is 10:38 AM.

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"