Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Yes/No Msgbx doesn't follow directions

I have written the following lines:
Range(Person).Select
If Range(Person).Select "" Then
resp = MsgBox("The person you have selected already has comments." &
Chr(13) & "Do you want to overwrite?", 4, WARNING)
If Response = vbNo Then
Windows("Personwin").Close
Exit Sub
If Response = vbYes Then
End If
End If
End If

Basically the person can change depending on the input. But, each person has
their own column and if the column already has comments, then I want to be
sure the user wants to write over these comments.

If the answer is 'no', then I want the window closed that was opened to
receive the comments (Personwin).

If the answer is 'yes', then I want the macro to continue with recording the
comments, etc.

When the macro runs and I click 'no', the macro continues instead of closin
the window and stopping.

Can someone please explain what I did wrong?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Yes/No Msgbx doesn't follow directions

Hi,

Maybe something like this

Range("Person").Select
If Range("Person").Value < "" Then
Resp = MsgBox("The person you have selected already has comments." & _
Chr(13) & "Do you want to overwrite?", vbYesNo, "WARNING")
If Resp = vbYes Then
MsgBox "User pressed OK what do you want to do?"
Else
Windows("Personwin").Close
Exit Sub
End If
End If

Mike

"iashorty" wrote:

I have written the following lines:
Range(Person).Select
If Range(Person).Select "" Then
resp = MsgBox("The person you have selected already has comments." &
Chr(13) & "Do you want to overwrite?", 4, WARNING)
If Response = vbNo Then
Windows("Personwin").Close
Exit Sub
If Response = vbYes Then
End If
End If
End If

Basically the person can change depending on the input. But, each person has
their own column and if the column already has comments, then I want to be
sure the user wants to write over these comments.

If the answer is 'no', then I want the window closed that was opened to
receive the comments (Personwin).

If the answer is 'yes', then I want the macro to continue with recording the
comments, etc.

When the macro runs and I click 'no', the macro continues instead of closin
the window and stopping.

Can someone please explain what I did wrong?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Yes/No Msgbx doesn't follow directions

The yes sequence is hundreds of lines long because it is basically saying
continue with the macro. This is why I was trying to put the 'no' first. The
'no is simply close; the 'yes' then ends the if and continues on.


"Mike H" wrote:

Hi,

Maybe something like this

Range("Person").Select
If Range("Person").Value < "" Then
Resp = MsgBox("The person you have selected already has comments." & _
Chr(13) & "Do you want to overwrite?", vbYesNo, "WARNING")
If Resp = vbYes Then
MsgBox "User pressed OK what do you want to do?"
Else
Windows("Personwin").Close
Exit Sub
End If
End If

Mike

"iashorty" wrote:

I have written the following lines:
Range(Person).Select
If Range(Person).Select "" Then
resp = MsgBox("The person you have selected already has comments." &
Chr(13) & "Do you want to overwrite?", 4, WARNING)
If Response = vbNo Then
Windows("Personwin").Close
Exit Sub
If Response = vbYes Then
End If
End If
End If

Basically the person can change depending on the input. But, each person has
their own column and if the column already has comments, then I want to be
sure the user wants to write over these comments.

If the answer is 'no', then I want the window closed that was opened to
receive the comments (Personwin).

If the answer is 'yes', then I want the macro to continue with recording the
comments, etc.

When the macro runs and I click 'no', the macro continues instead of closin
the window and stopping.

Can someone please explain what I did wrong?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Yes/No Msgbx doesn't follow directions

In your post you have resp = MsgBox

Not Response = MsgBox

If Response = vbNo Then 'Should be if resp = vbNo
"iashorty" wrote:

I have written the following lines:
Range(Person).Select
If Range(Person).Select "" Then
resp = MsgBox("The person you have selected already has comments." &
Chr(13) & "Do you want to overwrite?", 4, WARNING)
If Response = vbNo Then
Windows("Personwin").Close
Exit Sub
If Response = vbYes Then
End If
End If
End If

Basically the person can change depending on the input. But, each person has
their own column and if the column already has comments, then I want to be
sure the user wants to write over these comments.

If the answer is 'no', then I want the window closed that was opened to
receive the comments (Personwin).

If the answer is 'yes', then I want the macro to continue with recording the
comments, etc.

When the macro runs and I click 'no', the macro continues instead of closin
the window and stopping.

Can someone please explain what I did wrong?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Yes/No Msgbx doesn't follow directions

I tried the following:
Range(Person).Select
If Range(Person).Select "" Then
resp = MsgBox("The person you have selected already has comments." &
Chr(13) & "Do you want to overwrite?", 4, WARNING)
If Response = vbNo Then
Windows("Personwin").Close
Exit Sub
Else
End If
End If

I reads the If Response line and then skips to the End if lines.


"Mike H" wrote:

Hi,

Maybe something like this

Range("Person").Select
If Range("Person").Value < "" Then
Resp = MsgBox("The person you have selected already has comments." & _
Chr(13) & "Do you want to overwrite?", vbYesNo, "WARNING")
If Resp = vbYes Then
MsgBox "User pressed OK what do you want to do?"
Else
Windows("Personwin").Close
Exit Sub
End If
End If

Mike

"iashorty" wrote:

I have written the following lines:
Range(Person).Select
If Range(Person).Select "" Then
resp = MsgBox("The person you have selected already has comments." &
Chr(13) & "Do you want to overwrite?", 4, WARNING)
If Response = vbNo Then
Windows("Personwin").Close
Exit Sub
If Response = vbYes Then
End If
End If
End If

Basically the person can change depending on the input. But, each person has
their own column and if the column already has comments, then I want to be
sure the user wants to write over these comments.

If the answer is 'no', then I want the window closed that was opened to
receive the comments (Personwin).

If the answer is 'yes', then I want the macro to continue with recording the
comments, etc.

When the macro runs and I click 'no', the macro continues instead of closin
the window and stopping.

Can someone please explain what I did wrong?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Yes/No Msgbx doesn't follow directions

that was it, thank you.


"Mike" wrote:

In your post you have resp = MsgBox

Not Response = MsgBox

If Response = vbNo Then 'Should be if resp = vbNo
"iashorty" wrote:

I have written the following lines:
Range(Person).Select
If Range(Person).Select "" Then
resp = MsgBox("The person you have selected already has comments." &
Chr(13) & "Do you want to overwrite?", 4, WARNING)
If Response = vbNo Then
Windows("Personwin").Close
Exit Sub
If Response = vbYes Then
End If
End If
End If

Basically the person can change depending on the input. But, each person has
their own column and if the column already has comments, then I want to be
sure the user wants to write over these comments.

If the answer is 'no', then I want the window closed that was opened to
receive the comments (Personwin).

If the answer is 'yes', then I want the macro to continue with recording the
comments, etc.

When the macro runs and I click 'no', the macro continues instead of closin
the window and stopping.

Can someone please explain what I did wrong?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Yes/No Msgbx doesn't follow directions

The yes sequence is hundreds of lines long because it is basically saying
continue with the macro. This is why I was trying to put the 'no' first. The
'no is simply close; the 'yes' then ends the if and continues on.

Just a follow up on your comments above. In an If...Then statement where
the choice is yes or no, it really does not matter which option is tested
first because only the one that is true is going to execute anyhow. In other
words, if Resp did not equal vbYes, then VBA would ignore any executable
command and then test for the If Resp = vbNo criteria. It will only execute
the statement that is true.

"iashorty" wrote:

that was it, thank you.


"Mike" wrote:

In your post you have resp = MsgBox

Not Response = MsgBox

If Response = vbNo Then 'Should be if resp = vbNo
"iashorty" wrote:

I have written the following lines:
Range(Person).Select
If Range(Person).Select "" Then
resp = MsgBox("The person you have selected already has comments." &
Chr(13) & "Do you want to overwrite?", 4, WARNING)
If Response = vbNo Then
Windows("Personwin").Close
Exit Sub
If Response = vbYes Then
End If
End If
End If

Basically the person can change depending on the input. But, each person has
their own column and if the column already has comments, then I want to be
sure the user wants to write over these comments.

If the answer is 'no', then I want the window closed that was opened to
receive the comments (Personwin).

If the answer is 'yes', then I want the macro to continue with recording the
comments, etc.

When the macro runs and I click 'no', the macro continues instead of closin
the window and stopping.

Can someone please explain what I did wrong?

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
Looking up and create driving directions JackR Excel Discussion (Misc queries) 2 February 1st 09 04:53 PM
Need general directions StumpedAgain Excel Programming 3 August 14th 08 11:49 AM
web query for driving directions steve Excel Programming 2 March 11th 08 04:03 AM
V/HLOOKUP in both directions? thexdane Excel Worksheet Functions 5 November 15th 07 03:31 PM
Lookup 2 directions Tony Excel Worksheet Functions 1 March 28th 06 04:12 AM


All times are GMT +1. The time now is 10:18 PM.

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"