PC Review


Reply
Thread Tools Rate Thread

Combobox list to leave ONLY related values in list ??

 
 
Corey
Guest
Posts: n/a
 
      4th Jan 2007
I currently have combobox1 populated with values from sheet1.Range(R2:R12)

Combobox2 is populated with ALL Numerical values in sheet1.Range(A:A).

But i want ONLY Combobox2 populated with ALL Numerical values that have
..offset(-1,2).value = combobox1.value

The code to popultate combobox2 currently is:

Private Sub UserForm_Initialize()
Application.ScreenUpdating = False
With ActiveWorkbook.workSheets1
..Select
For myrow = 2 To lastcell
If .Cells(myrow, 1) <> "" Then
If IsNumeric(Trim(Mid(.Cells(myrow, 1), 2))) = True Then
ComboBox2.AddItem Cells(myrow, 1)
End If
End If

Next
End With
End Sub

Need something like:

Private Sub UserForm_Initialize()
Application.ScreenUpdating = False
If combobox2.value offset(-1, 2).value <> combobox1.value then REMOVE from
Combobox2.list ' <========= This bit here
With ActiveWorkbook.workSheets1
..Select
For myrow = 2 To lastcell
If .Cells(myrow, 1) <> "" Then
If IsNumeric(Trim(Mid(.Cells(myrow, 1), 2))) = True Then
ComboBox2.AddItem Cells(myrow, 1)
End If
End If

Next
End With
End Sub

Have been assisted with some other code to find the cell and it may be
needed to fix the above:

Dim rngFound As Range
On Error Resume Next
With workSheets2.Range("C:C")
Set rngFound = .Find(what:=Me.ComboBox1.Value, after:=.Range("C1"),
LookIn:=xlValues, lookat:=xlPart, searchorder:=xlByRows,
searchdirection:=xlNext, MatchCase:=False, matchbyte:=False)
' Top Section Values


Tough one for me to work out.

Corey....


 
Reply With Quote
 
 
 
 
Mike Fogleman
Guest
Posts: n/a
 
      4th Jan 2007
Corey, instead of trying to remove them, just exclude them from being added
to the combobox with a 3rd IF statement:

For myrow = 2 To lastcell
If .Cells(myrow, 1) <> "" Then
If .Cells(myrow, 1).Offset(-1, 2).value <> combobox1.value Then
If IsNumeric(Trim(Mid(.Cells(myrow, 1), 2))) = True Then
ComboBox2.AddItem Cells(myrow, 1)
End If
End If
End If
Next

Mike F

"Corey" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>I currently have combobox1 populated with values from sheet1.Range(R2:R12)
>
> Combobox2 is populated with ALL Numerical values in sheet1.Range(A:A).
>
> But i want ONLY Combobox2 populated with ALL Numerical values that have
> .offset(-1,2).value = combobox1.value
>
> The code to popultate combobox2 currently is:
>
> Private Sub UserForm_Initialize()
> Application.ScreenUpdating = False
> With ActiveWorkbook.workSheets1
> .Select
> For myrow = 2 To lastcell
> If .Cells(myrow, 1) <> "" Then
> If IsNumeric(Trim(Mid(.Cells(myrow, 1), 2))) = True Then
> ComboBox2.AddItem Cells(myrow, 1)
> End If
> End If
>
> Next
> End With
> End Sub
>
> Need something like:
>
> Private Sub UserForm_Initialize()
> Application.ScreenUpdating = False
> If combobox2.value offset(-1, 2).value <> combobox1.value then REMOVE from
> Combobox2.list ' <========= This bit here
> With ActiveWorkbook.workSheets1
> .Select
> For myrow = 2 To lastcell
> If .Cells(myrow, 1) <> "" Then
> If IsNumeric(Trim(Mid(.Cells(myrow, 1), 2))) = True Then
> ComboBox2.AddItem Cells(myrow, 1)
> End If
> End If
>
> Next
> End With
> End Sub
>
> Have been assisted with some other code to find the cell and it may be
> needed to fix the above:
>
> Dim rngFound As Range
> On Error Resume Next
> With workSheets2.Range("C:C")
> Set rngFound = .Find(what:=Me.ComboBox1.Value, after:=.Range("C1"),
> LookIn:=xlValues, lookat:=xlPart, searchorder:=xlByRows,
> searchdirection:=xlNext, MatchCase:=False, matchbyte:=False)
> ' Top Section Values
>
>
> Tough one for me to work out.
>
> Corey....
>



 
Reply With Quote
 
Corey
Guest
Posts: n/a
 
      4th Jan 2007
Thanks Mike,
Got there in the end with a few added conditions and a bit of fiddling
around.

Corey....
"Mike Fogleman" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Corey, instead of trying to remove them, just exclude them from being
> added to the combobox with a 3rd IF statement:
>
> For myrow = 2 To lastcell
> If .Cells(myrow, 1) <> "" Then
> If .Cells(myrow, 1).Offset(-1, 2).value <> combobox1.value Then
> If IsNumeric(Trim(Mid(.Cells(myrow, 1), 2))) = True Then
> ComboBox2.AddItem Cells(myrow, 1)
> End If
> End If
> End If
> Next
>
> Mike F
>
> "Corey" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>I currently have combobox1 populated with values from sheet1.Range(R2:R12)
>>
>> Combobox2 is populated with ALL Numerical values in sheet1.Range(A:A).
>>
>> But i want ONLY Combobox2 populated with ALL Numerical values that have
>> .offset(-1,2).value = combobox1.value
>>
>> The code to popultate combobox2 currently is:
>>
>> Private Sub UserForm_Initialize()
>> Application.ScreenUpdating = False
>> With ActiveWorkbook.workSheets1
>> .Select
>> For myrow = 2 To lastcell
>> If .Cells(myrow, 1) <> "" Then
>> If IsNumeric(Trim(Mid(.Cells(myrow, 1), 2))) = True Then
>> ComboBox2.AddItem Cells(myrow, 1)
>> End If
>> End If
>>
>> Next
>> End With
>> End Sub
>>
>> Need something like:
>>
>> Private Sub UserForm_Initialize()
>> Application.ScreenUpdating = False
>> If combobox2.value offset(-1, 2).value <> combobox1.value then REMOVE
>> from Combobox2.list ' <========= This bit here
>> With ActiveWorkbook.workSheets1
>> .Select
>> For myrow = 2 To lastcell
>> If .Cells(myrow, 1) <> "" Then
>> If IsNumeric(Trim(Mid(.Cells(myrow, 1), 2))) = True Then
>> ComboBox2.AddItem Cells(myrow, 1)
>> End If
>> End If
>>
>> Next
>> End With
>> End Sub
>>
>> Have been assisted with some other code to find the cell and it may be
>> needed to fix the above:
>>
>> Dim rngFound As Range
>> On Error Resume Next
>> With workSheets2.Range("C:C")
>> Set rngFound = .Find(what:=Me.ComboBox1.Value, after:=.Range("C1"),
>> LookIn:=xlValues, lookat:=xlPart, searchorder:=xlByRows,
>> searchdirection:=xlNext, MatchCase:=False, matchbyte:=False)
>> ' Top Section Values
>>
>>
>> Tough one for me to work out.
>>
>> Corey....
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combobox List to list Numerical Values ONLY in Column A is specific Sheet.... Corey Microsoft Excel Programming 5 28th Dec 2006 10:40 AM
List Values in a Combobox ZEP Microsoft Access Forms 2 16th Dec 2005 12:22 AM
List Values in a Combobox ZEP Microsoft Access Form Coding 2 16th Dec 2005 12:22 AM
List Values in a Combobox =?Utf-8?B?WkVQ?= Microsoft Access Forms 0 7th Dec 2005 05:58 PM
Values contained in value list of second combobox based on value selected in first combobox. Anthony Microsoft Access Forms 16 6th Mar 2004 04:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:45 AM.