#1   Report Post  
Greg B
 
Posts: n/a
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  
Dave Peterson
 
Posts: n/a
Default

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  
Greg B
 
Posts: n/a
Default

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
Possibly a loaded question, but I think mileslit Excel Discussion (Misc queries) 1 September 10th 05 01:18 AM
How do I find and replace a question mark in Excel? Ranpalandil Excel Discussion (Misc queries) 1 September 7th 05 10:20 PM
Hints And Tips For New Posters In The Excel Newsgroups Gary Brown Excel Worksheet Functions 0 April 15th 05 05:47 PM
Question about combining data from multiple workbooks into one rep BookOpenandUpright Excel Discussion (Misc queries) 2 February 19th 05 12:37 PM
An easy macro question and one I believe to be a little more diffi TroutKing Excel Worksheet Functions 3 January 18th 05 09:17 PM


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