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: 1,814
Default Checking a listbox

Hi

I have the following code that creates a list of Months that just happen to
correspond to Tab names in my sheet. This works fine.

However, I have a ListBox1_Click routine that when I select the particular
date it lists all the data from 2 of the columns in that tab.

It all works OK if I have 3 or more lines worth of data (not including
header) but if I only have one line of data, not including header then it
just hangs. When I do a Funtion Break it highlights the "Next" which I guess
means it is stuck in a loop.

I have already had to add the Msg "Month Empty" to stop it throwing an error
then.

Admittidly I did copy this code from somewhere else and tried to adapt it.

Any help would be appreciated.

If EditListBox1.ListIndex < -1 Then
EditListBox2.Clear
Set sh = Worksheets(EditListBox1.Value)
If sh.Cells(2, 1).Value < "" Then
Set rng = sh.Range(sh.Cells(2, 1), sh.Cells(2, 1).End(xlDown))
For Each cell In rng
EditListBox2.AddItem cell(1, 1).Value & " " & cell(1, 3).Value
Next
Else
MsgBox "Month is empty"
End If
End If
 
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
Spell Checking with checking cell notes jfitzpat Excel Discussion (Misc queries) 0 August 8th 07 10:26 PM
Checking range of cells for entry then checking for total Barb Reinhardt Excel Programming 1 October 13th 06 02:47 PM
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) modjoe23 Excel Programming 3 August 18th 05 02:35 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Checking Listbox Items Tim[_15_] Excel Programming 1 July 20th 03 05:27 PM


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