Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting a ListBox range

Hi there,

I am a novice at using VB and need some help.
I have created a list box that pulls it's info from another shee
labled "database". I need to be able to select a row from that list bo
and have certian values from that row pasted on another sheet. I hav
been able to paste the info but only from the last row that appears
not the one that is selected. I've though something along the lines o
Listbox_click event but don't know how to use it :( Here is the cod
that i have so far:

Dim BSapp_v2 As Workbook
Dim shtbsmain As Worksheet
Dim shtdatabase As Worksheet
Dim cl As Integer


Private Sub UserForm_Activate()
With Sheets("database")
For cl = 2 To 5000
If .Cells(cl, 4) = "" Then Exit For
Next
End With
cl = cl - 1
progListBox.RowSource = "database!$A$2:$V$" & Mid(Str(cl), 2)
End Sub

Private Sub btnOpen_Click()
If IsNull(progListBox) Then
Beep
MsgBox "No Reference Selected!", vbExclamation, ""
Exit Sub
End If

With Sheets("DataBase")

Load:
Range("Issr_local") = .Cells(cl, 2)
Range("Principal") = .Cells(cl, 4)

End With
Hide
End Sub

Private Sub btnCancel_Click()
Hide
End Sub

Any help would be greatly appreciated. Thank you for your time.

Jo

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selecting a ListBox range

isnull doesn't work in that situation

Private Sub btnOpen_Click()
If progListBox.ListIndex = -1 Then
Beep
MsgBox "No Reference Selected!", vbExclamation, ""
Exit Sub
End If
set rng = Range(progListbox.RowSource).Columns(1).Cells
cl = rng.Offset(prog.ListBox.ListIndex,0).Row
With Sheets("DataBase")

Load:
Range("Issr_local") = .Cells(cl, 2)
Range("Principal") = .Cells(cl, 4)

End With
Hide
End Sub

--
Regards,
Tom Ogilvy


"JoeH " wrote in message
...
Hi there,

I am a novice at using VB and need some help.
I have created a list box that pulls it's info from another sheet
labled "database". I need to be able to select a row from that list box
and have certian values from that row pasted on another sheet. I have
been able to paste the info but only from the last row that appears,
not the one that is selected. I've though something along the lines of
Listbox_click event but don't know how to use it :( Here is the code
that i have so far:

Dim BSapp_v2 As Workbook
Dim shtbsmain As Worksheet
Dim shtdatabase As Worksheet
Dim cl As Integer


Private Sub UserForm_Activate()
With Sheets("database")
For cl = 2 To 5000
If .Cells(cl, 4) = "" Then Exit For
Next
End With
cl = cl - 1
progListBox.RowSource = "database!$A$2:$V$" & Mid(Str(cl), 2)
End Sub

Private Sub btnOpen_Click()
If IsNull(progListBox) Then
Beep
MsgBox "No Reference Selected!", vbExclamation, ""
Exit Sub
End If

With Sheets("DataBase")

Load:
Range("Issr_local") = .Cells(cl, 2)
Range("Principal") = .Cells(cl, 4)

End With
Hide
End Sub

Private Sub btnCancel_Click()
Hide
End Sub

Any help would be greatly appreciated. Thank you for your time.

Joe


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting a ListBox range

Tom,

Thanks for the quick reply. I replaced the section and now i a
getting a -- Runtime Error 424 Object Required. The debugger shows Thi
line as the 'offender'

cl = rng.Offset(prog.ListBox.ListIndex, 0).Row

I tried declaring RNG as an integer and got the same error (don't kno
if needed or not but thought it was worth a try)

Any more hints ??

Again thanks
Jo

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting a ListBox range

TOM !!!!

Nevermind.... I just needed to clear the sleep from my eyes and remov
a period !!!!!!

It's deffinatly time to get some rest. It's been a long weekend !

Thanks again for the quick and perfectly working response !!!

Jo

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selecting a ListBox range

Yes, my typo. Sorry for that.

--
Regards,
Tom Ogilvy


"JoeH " wrote in message
...
TOM !!!!

Nevermind.... I just needed to clear the sleep from my eyes and remove
a period !!!!!!

It's deffinatly time to get some rest. It's been a long weekend !

Thanks again for the quick and perfectly working response !!!

Joe


---
Message posted from http://www.ExcelForum.com/



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
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Selecting Multiple items in ListBox Dave Peterson[_3_] Excel Programming 0 August 26th 04 01:33 AM
Selecting multiple items and columns from ListBox TK Excel Programming 0 August 25th 04 01:19 AM
Multicolumn ListBox in Userforms (selecting specific rows) wpllc2004 Excel Programming 1 April 6th 04 08:45 PM
Selecting multiple rows from listbox for reporting Brett9[_2_] Excel Programming 3 November 5th 03 11:07 AM


All times are GMT +1. The time now is 11:46 PM.

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"