#1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default If Question

I am trying to make a macro where it is connected to a listbox. I have a
problem of if a blank cell of the listbox is hit by accident it comes up
with the debug error. I am trying to get around this by writing a "IF" code
but am a little stuck.

I have this at the moment

ActiveSheet.Range("A1").Offset(ListBox1.ListIndex) .Select
If ActiveCell = "" Then
MsgBox ("idiot")
End If

Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

How do I only get it to go to the hyperlink section of the code only if the
cell it chooses has text in it to fire the
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
part of the code

Any help would be great

Thanks
GReg


  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default If Question

Maybe just checking for a hyperlink first...

if selection.hyperlinks.count 0 then
selection.hyperlinks(1).follow ....etc
else
msgbox "no link"
end if


Greg B wrote:

I am trying to make a macro where it is connected to a listbox. I have a
problem of if a blank cell of the listbox is hit by accident it comes up
with the debug error. I am trying to get around this by writing a "IF" code
but am a little stuck.

I have this at the moment

ActiveSheet.Range("A1").Offset(ListBox1.ListIndex) .Select
If ActiveCell = "" Then
MsgBox ("idiot")
End If

Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

How do I only get it to go to the hyperlink section of the code only if the
cell it chooses has text in it to fire the
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
part of the code

Any help would be great

Thanks
GReg


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default If Question

Thank you Dave

Works Great
Greg
"Dave Peterson" wrote in message
...
Maybe just checking for a hyperlink first...

if selection.hyperlinks.count 0 then
selection.hyperlinks(1).follow ....etc
else
msgbox "no link"
end if


Greg B wrote:

I am trying to make a macro where it is connected to a listbox. I have a
problem of if a blank cell of the listbox is hit by accident it comes up
with the debug error. I am trying to get around this by writing a "IF"
code
but am a little stuck.

I have this at the moment

ActiveSheet.Range("A1").Offset(ListBox1.ListIndex) .Select
If ActiveCell = "" Then
MsgBox ("idiot")
End If

Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True

How do I only get it to go to the hyperlink section of the code only if
the
cell it chooses has text in it to fire the
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
part of the code

Any help would be great

Thanks
GReg


--

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
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good davegb Excel Programming 1 May 6th 05 06:35 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 27th 05 07:46 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 23 April 23rd 05 09:26 PM
Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good you [email protected] Excel Programming 0 April 22nd 05 03:30 PM


All times are GMT +1. The time now is 01:58 PM.

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"