Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Populate Sheet based on ComboBox selection

Hello. On Sheet2 I have a combo box. On sheet1 ColA, I have the
"key" for the combobox selections. So if I choose "Product1" from the
combobox, how do I have vba bring in all the rows that have "Product1"
in Column A? Bringing in the entire row, or columns 1 thru 8 would be
fine. Thanks!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default Populate Sheet based on ComboBox selection

What do you mean by "bring in" ? Hide?

--JP

On Mar 4, 7:54*pm, Steve wrote:
Hello. *On Sheet2 I have a combo box. *On sheet1 ColA, I have the
"key" for the combobox selections. *So if I choose "Product1" from the
combobox, how do I have vba bring in all the rows that have "Product1"
in Column A? *Bringing in the entire row, or columns 1 thru 8 would be
fine. *Thanks!!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Populate Sheet based on ComboBox selection

No, more like copy the row from Sheet1 and paste it in Sheet2. Sheet1
will house all the data and be hidden. The combobox is on Sheet2, so
i would like the appropriate rows ro be pasted beginning on Row5.
Thanks!!

On Mar 4, 5:58*pm, JP wrote:
What do you mean by "bring in" ? Hide?

--JP

On Mar 4, 7:54*pm, Steve wrote:



Hello. *On Sheet2 I have a combo box. *On sheet1 ColA, I have the
"key" for the combobox selections. *So if I choose "Product1" from the
combobox, how do I have vba bring in all the rows that have "Product1"
in Column A? *Bringing in the entire row, or columns 1 thru 8 would be
fine. *Thanks!!- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default Populate Sheet based on ComboBox selection

Is the combo box on a userform? It's much easier that way. I created a
test userform with a single combo box which takes the range in sheet
1, column A and copies matching rows to Sheet 2. It's not much but it
does exactly what you want.

Here is the code behind the userform:

Private Sub CommandButton1_Click()
Dim cell As Excel.Range
Dim rng As Excel.Range

For Each cell In Worksheets("Sheet1").Range("A1",
Range("A65536").End(xlUp))
Set rng = Worksheets("Sheet2").Range("A4")

If CLng(cell.Value) = ComboBox1.Value Then
cell.EntireRow.Copy rng.Offset(1, 0)
End If

Next cell
End Sub

Private Sub CommandButton2_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim cell As Excel.Range

For Each cell In Worksheets("Sheet1").Range("A1",
Range("A65536").End(xlUp))
ComboBox1.AddItem CLng(cell.Value)
Next cell

End Sub


If you like I can email you a copy.

HTH,
JP



On Mar 4, 8:05*pm, Steve wrote:
No, more like copy the row from Sheet1 and paste it in Sheet2. *Sheet1
will house all the data and be hidden. *The combobox is on Sheet2, so
i would like the appropriate rows ro be pasted beginning on Row5.
Thanks!!

On Mar 4, 5:58*pm, JP wrote:



What do you mean by "bring in" ? Hide?


--JP


On Mar 4, 7:54*pm, Steve wrote:


Hello. *On Sheet2 I have a combo box. *On sheet1 ColA, I have the
"key" for the combobox selections. *So if I choose "Product1" from the
combobox, how do I have vba bring in all the rows that have "Product1"
in Column A? *Bringing in the entire row, or columns 1 thru 8 would be
fine. *Thanks!!- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Populate Sheet based on ComboBox selection

Hi JP. Thanks for the responses. My combo box is NOT in a user
form. Didn't want to mess with loading the form or clicking the "go"
button. My combo box populates based on the user id and happend via
an open-workbook event. Is the code dramatically different if i use
the combo box from the control toolbox? THats how i have the file
built now...rather not mess with it! Thanks JP!!

On Mar 4, 6:37*pm, JP wrote:
Is the combo box on a userform? It's much easier that way. I created a
test userform with a single combo box which takes the range in sheet
1, column A and copies matching rows to Sheet 2. It's not much but it
does exactly what you want.

Here is the code behind the userform:

Private Sub CommandButton1_Click()
Dim cell As Excel.Range
Dim rng As Excel.Range

For Each cell In Worksheets("Sheet1").Range("A1",
Range("A65536").End(xlUp))
Set rng = Worksheets("Sheet2").Range("A4")

If CLng(cell.Value) = ComboBox1.Value Then
* * cell.EntireRow.Copy rng.Offset(1, 0)
End If

Next cell
End Sub

Private Sub CommandButton2_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim cell As Excel.Range

For Each cell In Worksheets("Sheet1").Range("A1",
Range("A65536").End(xlUp))
* * ComboBox1.AddItem CLng(cell.Value)
Next cell

End Sub

If you like I can email you a copy.

HTH,
JP

On Mar 4, 8:05*pm, Steve wrote:



No, more like copy the row from Sheet1 and paste it in Sheet2. *Sheet1
will house all the data and be hidden. *The combobox is on Sheet2, so
i would like the appropriate rows ro be pasted beginning on Row5.
Thanks!!


On Mar 4, 5:58*pm, JP wrote:


What do you mean by "bring in" ? Hide?


--JP


On Mar 4, 7:54*pm, Steve wrote:


Hello. *On Sheet2 I have a combo box. *On sheet1 ColA, I have the
"key" for the combobox selections. *So if I choose "Product1" from the
combobox, how do I have vba bring in all the rows that have "Product1"
in Column A? *Bringing in the entire row, or columns 1 thru 8 would be
fine. *Thanks!!- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


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
Populate Adjacent Cells based on Pull Down Selection edvwvw via OfficeKB.com New Users to Excel 0 June 30th 09 01:28 PM
How to populate a combobox based on selection from another combobo LinnT Excel Programming 6 November 23rd 07 09:23 AM
Auto Populate Based on Other Selection Kate Excel Discussion (Misc queries) 2 May 15th 07 10:57 PM
How do i populate a text box according to selection in combobox? Steve Excel Worksheet Functions 0 April 13th 06 12:40 PM
Having data populate text boxes based on Combobox Value Todd Huttenstine[_2_] Excel Programming 1 November 10th 03 01:35 AM


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