Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - "IF Answer = Problem"

I'm using the code below to make a msgbox:

Answer = MsgBox("Do you wish to open part one ?", _
vbOKCancel, "My Title")
If Answer = vbCancel Then Exit Sub
If Answer = vbOK Then ActiveWorkbook.FollowHyperlink Address:= _
"Q:\path is here\baook1.xls" _
, NewWindow:=False, AddHistory:=True
Sheets("Mar_04").Select
Range("A1").Select

But it isnt working and I have no idea how to fix this problem. An
helpmwould be greatly appreciated. :

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Excel VBA - "IF Answer = Problem"

Hi,

I'm note quite sure, but I think you have to write the End If statement
every time:

If Answer = vbCancel Then
Exit Sub
End If

If Answer = vbOK Then
ActiveWorkbook.FollowHyperlink Address:= [...]
End If



The better version for this would be:

If Answer = vbCancel Then
Exit Sub
Else
ActiveWorkbook.FollowHyperlink Address:= [...]
End If



Regards, Thomas
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Excel VBA - "IF Answer = Problem"

Fraggs,

It would help if you told us what isn't working. I tested it and it worked
for me.

How did you declare Answer, it should not be a string or range?

Post back more details.

--

HTH

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

"Fraggs " wrote in message
...
I'm using the code below to make a msgbox:

Answer = MsgBox("Do you wish to open part one ?", _
vbOKCancel, "My Title")
If Answer = vbCancel Then Exit Sub
If Answer = vbOK Then ActiveWorkbook.FollowHyperlink Address:= _
"Q:\path is here\baook1.xls" _
, NewWindow:=False, AddHistory:=True
Sheets("Mar_04").Select
Range("A1").Select

But it isnt working and I have no idea how to fix this problem. Any
helpmwould be greatly appreciated. :)


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Excel VBA - "IF Answer = Problem"

Hi Fraggs

Mimicking your code I had the same problem. Looking in the Excel VBA help
file I noticed the following in
the FollowHyperlink Method:
AddHistory Optional Variant. Not used. Reserved for future use.

I got rid of the AddHistory parameter and everthing was fine.

Do likewise and yours should work too

If Answer = vbOK Then ActiveWorkbook.FollowHyperlink Address:= _
"Q:\path is here\baook1.xls" _
, NewWindow:=False


Regards

Paul


"Fraggs " wrote in message
...
I'm using the code below to make a msgbox:

Answer = MsgBox("Do you wish to open part one ?", _
vbOKCancel, "My Title")
If Answer = vbCancel Then Exit Sub
If Answer = vbOK Then ActiveWorkbook.FollowHyperlink Address:= _
"Q:\path is here\baook1.xls" _
, NewWindow:=False, AddHistory:=True
Sheets("Mar_04").Select
Range("A1").Select

But it isnt working and I have no idea how to fix this problem. Any
helpmwould be greatly appreciated. :)


---
Message posted from http://www.ExcelForum.com/



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
VLOOKUP displaying "NO ANSWER" instead of "0" ksean Excel Worksheet Functions 2 April 22nd 09 03:18 AM
How do I write an excel formula with a text answer ("yes" or "no") pat Excel Discussion (Misc queries) 1 September 9th 08 03:41 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
disregard 12/19/05 ".XValues syntax problem" question. Answer fou JF_01 Charts and Charting in Excel 1 December 19th 05 08:22 PM


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