View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
John Coleman John Coleman is offline
external usenet poster
 
Posts: 274
Default Calling my macro is only working if certain options are selected

Hi

Mike is correct that sub addNewSheet will be called no matter what -
so it would help if you included the code for the sub and a
description of what you expect it to do.

One thought - you described this code fragment as being on the bottom
of a larger sub. If you have an On Error Resume Next statement earlier
(a dangerous statement in general) and addNewSheet hits an error
condition in the case "no" was selected, then it might appear as if
nothing happened whereas in reality a bug was encountered then swept
under the rug. If so, comment out the On Error statement and see what
happens.

Did you try stepping through the macro to see what happens?

Hth

-John Coleman

On Mar 29, 8:51 am, wrote:
Hi there I have attached at the bottom a piece of code from a
questionnaire I have made (with lots of help) and it calls a macro
called addNewSheet at the end - for some reason this only works if
they select yes for the final bit and if they select no nothing
happens. Would anyone know where I am going wrong?

detri = MsgBox("Question 4e. Could this information have had a
detrimental effect on KM if it fell into the wrong hands?", vbYesNo)
If detri = vbYes Then
Range("D18") = "Question 4e. Could this information have had a
detrimental effect on KM if it fell into the wrong hands?"
Range("E18") = "Yes"
Range("E18").Font.ColorIndex = 5
WhyDetri = InputBox("Question 4f. Why?")
Range("D19") = "Question 4f. Why?"
Range("E19") = WhyDetri
Range("E19").Font.ColorIndex = 5
Columns("E").AutoFit
Range("D13:E19").BorderAround ColorIndex:=xlAutomatic,
Weight:=xlMedium
Range("D13:E19").Borders(xlInsideHorizontal).LineS tyle =
xlContinuous
Range("D13:E19").Borders(xlInsideVertical).LineSty le =
xlContinuous
Else
Range("D18") = "Question 4e. Could this information have had a
detrimental effect on KM if it fell into the wrong hands?"
Range("E18") = "No"
Range("E18").Font.ColorIndex = 5
Columns("E").AutoFit
Range("D13:E18").BorderAround ColorIndex:=xlAutomatic,
Weight:=xlMedium
Range("D13:E18").Borders(xlInsideHorizontal).LineS tyle =
xlContinuous
Range("D13:E18").Borders(xlInsideVertical).LineSty le =
xlContinuous

End If

Call addNewSheet

End Sub