Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Combobox list to leave ONLY related values in list ??

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....


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Combobox list to leave ONLY related values in list ??

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" wrote in message
...
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....



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Combobox list to leave ONLY related values in list ??

Thanks Mike,
Got there in the end with a few added conditions and a bit of fiddling
around.

Corey....
"Mike Fogleman" wrote in message
m...
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" wrote in message
...
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
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
.AddItem list and populating combobox with created list pallaver Excel Discussion (Misc queries) 8 June 27th 08 12:36 PM
Using Unique Values in as a combobox value list Ayo Excel Discussion (Misc queries) 0 March 7th 08 01:51 PM
Combobox List to list Numerical Values ONLY in Column A is specific Sheet.... Corey Excel Programming 5 December 28th 06 10:40 AM
How Do I Get A ComboBox To Add Entry To It's List If Not In List Minitman[_4_] Excel Programming 15 October 8th 05 03:28 AM
how to populate a combobox with a list of unique values? RIOSGER Excel Programming 2 August 9th 05 04:16 AM


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