Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
IP IP is offline
external usenet poster
 
Posts: 5
Default Find records that belong to a combo box value

I added a combo box to an Excel wks. I need to find all the records on the
same worksheet where column B value=ComboBox value. Then I need to copy the
records and paste into another worksheet.
Is there a way of doing this in Excel?
I appreciate any help. Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Find records that belong to a combo box value

If this is not what you are looking for, maybe you can adapt it to do what
you want. The code below goes into the Sheet code module for the sheet with
the combobox. To access the code module, right click the sheet tab and then
click View Code on the pop up menu. Copy the code below and paste it into
the code window that opens. Save the file and you are in business. When
you make a selection in the combobox, it will copy the rows for all matches
to sheet1.

Private Sub ComboBox1_Click()
Dim lr As Long, rng As Range
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Worksheets("Sheet1")
Set sh2 = Worksheets("Sheet2")
lr = sh1.Cells(Rows.Count, 2).End(xlUp).Row
Set rng = sh1.Range("B2:B" & lr)
For Each c In rng
If c.Value = Me.ComboBox1.Value Then
c.EntireRow.Copy _
sh2.Range("A" & sh2.Cells(Rows.Count, 2) _
.End(xlUp).Row + 1)
End If
Next
End Sub





"IP" wrote in message
...
I added a combo box to an Excel wks. I need to find all the records on the
same worksheet where column B value=ComboBox value. Then I need to copy
the
records and paste into another worksheet.
Is there a way of doing this in Excel?
I appreciate any help. Thank you.



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
Sorry for the cross post but this may belong in this section inste AZToad Excel Programming 0 July 29th 09 09:24 PM
scwewy answerrs that don't belong SteveDB1 Excel Worksheet Functions 16 December 28th 07 07:38 PM
Combo Box for a list of records dascooper Excel Worksheet Functions 2 November 16th 07 09:40 PM
Should Method Belong to the Class? Trip[_3_] Excel Programming 1 September 20th 05 09:29 PM
does an item belong to an array? wcc Excel Programming 4 October 21st 04 08:46 AM


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