#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default List Box

I have a macro that looks for the value in a list box and then runs a set of
macros.

I have the code to exit the Sub and display a message box if there isn't a
value selected from the list box.


If frmRefresh.ListBox3.Value = "" Then
Exit Sub
MsgBox "Select A Value from the List Box, vbOKOnly, "Error"
Else
Application.Run...............................
End If

It simply debugs later on because nothing is selected in the Listbox.

I need the wording for the If statement to stop the macro if nothing is
selected in the listbox.

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default List Box

Try...

If Trim(frmRefresh.ListBox3.Value) = "" Then
MsgBox "Select A Value from the List Box", vbOKOnly, "Error"
Exit Sub
Else
Application.Run...............................
End If

--
If this post helps click Yes
---------------
Jacob Skaria


"N1KO" wrote:

I have a macro that looks for the value in a list box and then runs a set of
macros.

I have the code to exit the Sub and display a message box if there isn't a
value selected from the list box.


If frmRefresh.ListBox3.Value = "" Then
Exit Sub
MsgBox "Select A Value from the List Box, vbOKOnly, "Error"
Else
Application.Run...............................
End If

It simply debugs later on because nothing is selected in the Listbox.

I need the wording for the If statement to stop the macro if nothing is
selected in the listbox.

Thanks in advance

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default List Box

Hi Jacob,

Unfortunately it doesn't work, it brings up and error box with an invalid
use of null.

Thank you very much though.

"Jacob Skaria" wrote:

Try...

If Trim(frmRefresh.ListBox3.Value) = "" Then
MsgBox "Select A Value from the List Box", vbOKOnly, "Error"
Exit Sub
Else
Application.Run...............................
End If

--
If this post helps click Yes
---------------
Jacob Skaria


"N1KO" wrote:

I have a macro that looks for the value in a list box and then runs a set of
macros.

I have the code to exit the Sub and display a message box if there isn't a
value selected from the list box.


If frmRefresh.ListBox3.Value = "" Then
Exit Sub
MsgBox "Select A Value from the List Box, vbOKOnly, "Error"
Else
Application.Run...............................
End If

It simply debugs later on because nothing is selected in the Listbox.

I need the wording for the If statement to stop the macro if nothing is
selected in the listbox.

Thanks in advance

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default List Box

strValue = frmRefresh.ListBox3.Text

If Trim(strValue) = "" Then
MsgBox "Select A Value from the List Box", vbOKOnly, "Error"
Exit Sub
Else
'Application.Run...............................
End If

If this post helps click Yes
---------------
Jacob Skaria


"N1KO" wrote:

Hi Jacob,

Unfortunately it doesn't work, it brings up and error box with an invalid
use of null.

Thank you very much though.

"Jacob Skaria" wrote:

Try...

If Trim(frmRefresh.ListBox3.Value) = "" Then
MsgBox "Select A Value from the List Box", vbOKOnly, "Error"
Exit Sub
Else
Application.Run...............................
End If

--
If this post helps click Yes
---------------
Jacob Skaria


"N1KO" wrote:

I have a macro that looks for the value in a list box and then runs a set of
macros.

I have the code to exit the Sub and display a message box if there isn't a
value selected from the list box.


If frmRefresh.ListBox3.Value = "" Then
Exit Sub
MsgBox "Select A Value from the List Box, vbOKOnly, "Error"
Else
Application.Run...............................
End If

It simply debugs later on because nothing is selected in the Listbox.

I need the wording for the If statement to stop the macro if nothing is
selected in the listbox.

Thanks in advance

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
Use VBA to reset data validation (=list) value to first value in that list (list is a named range) ker_01 Excel Programming 7 October 27th 08 03:13 PM
Compare List A to List B, Return List B Items Not in List A zwestbrook Excel Programming 4 September 18th 08 10:32 PM
validation list--list depends on the selection of first list Michael New Users to Excel 2 April 27th 06 10:23 PM
list 1 has 400 names List 2 has 4000. find manes from list 1 on 2 Ed Excel Worksheet Functions 5 September 12th 05 09:48 AM
find names on list 1 in list 2. list 1 4000 names list 2 400 name Ed Excel Worksheet Functions 1 September 4th 05 12:48 AM


All times are GMT +1. The time now is 06:59 AM.

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"