Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Listbox-2 entires should select by Clicking Listbox-1 entires. How

Dear Friends & Gurus,

I've 2 listboxes in my excel form one contains Employee Names and the other
Employee Id. This is for monitoring the manpower details on each month. There
may be case that 2 employees can have the same name, but their Employee Id
will be Unique. The user have a combo box where he can select the month
details, once selected then Listbox1 will be filled with the Employee Names
worked on that particualr month. If the HR Exec. wants to enter the details
of the Salary and the Allowances for the employees then he/she can select the
month name and then select the employee name from the listbox1 and click the
appropriate command buttons provided one for salary, another for allowances,
and etc.

For example the first 2 employees are having the same name, but with
different profile, salary and employee id. So when the user selects the first
employee name then a For....Loop will get activated and check for the
particular employee in that particular month. If the user selects the 2nd
employee with the same name then the loop will display the first employee
details. This I wish to achieve by checking the Employee Id in the
For....Loop, but I don't want that listbox2 contains the Employee Id to be
visible.

When the user selects or changes the month from the combo box then a
For....Loop will be activated and listbox1(Emp Name) and listbox2(Emp Id)
will get populated with employee names and employee ids respectively for that
particular selected month. Here listbox2(Emp Id) will be invisible to the
user always. Once he selects the employee name then the corresponding
selection should take place in listbox2 also.

If thes user selects the first employee name then in the listbox2 the first
entry should get selected automatically. As such if he selects the fourth
entry in list1 then 4th entry in list2 should get selected automatically and
based on that selection in the For....Loop it should check for the employee
id and details should get displayed. Belo is my code for that, but it is
giving some

Run-time error '-2417417848 (80010108): Method 'ListIndex' of object
'IMDcList' failed.

It is working for the first entry of the listbox1 and then all other entries
are giving this error.

Kindly suggest me what I should do to come out of this problem.

Here is the Code for that:
-----------------------------

Private Sub LstEmployeeNames_click()

ThisWorkbook.Sheets("Worksheet").Cells(12, 7) = "" 'Working Status

If LstEmployeeNames.Value < "" Then
LstRecordindex.ListIndex = LstEmployeeNames.ListIndex
'MsgBox LstRecordindex.Value

For I = 4 To LastLine - 1
If ThisWorkbook.Sheets("MP Data").Cells(I, 1) =
Val(LstRecordindex.Value) Then
ThisWorkbook.Sheets("Worksheet").Cells(12, 7) =
ThisWorkbook.Sheets("MP Data").Cells(I, 5)
ThisWorkbook.Sheets("Worksheet").Cells(16, 7) =
ThisWorkbook.Sheets("MP Data").Cells(I, 15)
ThisWorkbook.Sheets("Worksheet").Cells(20, 7) =
ThisWorkbook.Sheets("MP Data").Cells(I, 8)
ThisWorkbook.Sheets("Worksheet").Cells(21, 7) =
ThisWorkbook.Sheets("MP Data").Cells(I, 9)

Exit For
End If

Next I

End If

End Sub


Thanks in advance.

Sriram
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Listbox-2 entires should select by Clicking Listbox-1 entires. How

Hi

Why not just have 1 listbox with 2 columns. You can set the width of
the ID column to be zero and thus hidden. Would make life alot easier.

hth

Keith


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Listbox-2 entires should select by Clicking Listbox-1 entires.

Keith,

Thanks for your reply. I found out the probblem resolved the issue. Now it
is workign fine. The same solution one of my other friend (Excel Guru) told
me yesterday. Your both solution is the same and let me try to adopt this
once if I'm in need of that.

Thanks for your suggestion.

--
Regards,
Sriram Subramaniyan


"Keith74" wrote:

Hi

Why not just have 1 listbox with 2 columns. You can set the width of
the ID column to be zero and thus hidden. Would make life alot easier.

hth

Keith



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
Duplicate entires in multiple tabs Breezy New Users to Excel 1 November 3rd 09 03:08 PM
How to filter unique entires in a column when differnet entires in Sklyn Excel Worksheet Functions 13 October 2nd 09 02:24 AM
need help on count entires with conditions sajid Excel Worksheet Functions 8 November 3rd 08 12:31 PM
How can I check if any of the entires is True in a range? Tetsuya Oguma Excel Worksheet Functions 1 March 16th 06 02:37 AM
How to keep a running total on a col that has frequent new entires James Bond Excel Programming 2 August 20th 04 10:13 AM


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