LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Would like to getback a MsgBox on error

First let me say, Thanks to all the People that make this forum great!
All of my limited knowledge comes from browsing this forum and the referred
websites for ideas, and that is how I been able to make most of my simple
macros.

I have a ComboBox with a list, when I click on an item in the list, the
value unloads in the selected cell. I also created a UserForm with a ListBox
that is linked to the same List as the Combobox. The reason I wanted a
UserForm is because I can use the keyboard to navigate through the list and
the OK and Cancel buttons with out using the mouse. Also I wanted for the
list to only unload in range B5:B159" and nowhere else.
What I would like to do is to get a Msgbox, letting the user know that
nothing was done because the macro will only work on a Range B5:B159. I been
trying to use the If/Then commands but I'm not getting it right. Also the Ok
button does not work if not in Range B5:B159.
Thanks in Advance

This is what I have so far:

Private Sub CommandButton1_Click()
'if the listindex of listbox equals -1 ... nothing selected
If lstSelection.ListIndex = -1 Then
MsgBox "No item selected", vbExclamation
Exit Sub
End If
If Not Intersect(ActiveCell, Range("b5..b159")) Is Nothing Then
On Error GoTo 0
Range("SelectionLink") = lstSelection.ListIndex + 1
Selection.Cells(1) = Worksheets("Formulas").Range("D1")
Selection.Cells(1).Offset(0, 3) = Worksheets("Formulas").Range("E1")
Unload Me
End If
On Error GoTo 0
End Sub

Private Sub CommandButton2_Click()
Unload Me
End Sub

Private Sub lstSelection_Click()
End Sub
Private Sub UserForm_Click()
End Sub

KBrenner

 
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
MsgBox when an Error occurs Vick Excel Discussion (Misc queries) 1 December 21st 05 08:48 PM
msgbox appear with error msg jrd269 Excel Programming 3 June 2nd 05 04:18 PM
msgbox on error Ciara Excel Discussion (Misc queries) 6 May 26th 05 08:34 PM
MsgBox Code Error MBlake Excel Programming 8 May 2nd 05 11:16 PM
inputbox msgbox error lost again Excel Programming 3 April 14th 04 07:56 PM


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