Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Do i need a Next or Loop statement ?

The following code is part of a Userform to FIND Certain Values, provided there are Conditions Met.
The Data layout is:

A B C D E F G
1 FRED BLUE
2 615
3 25
4 31
5 87
6 7
7 60
8 75 <=== STRIKE THROUGH
9 20
10
11
12
13
14
15
16
17
18
19
20 JACK RED
21 614
22

etc.............


Therefore,
As i am LOOKING for a Numerical Value in Column C that,
1. Has a MATCHING value in Column C that is .Offset(-1, 2) from the ID Value in Column A that was
Selected in LISTBOX1, AND
2. Has a MATCHING value in Column G that is .Offset(-1, 6) from the ID Value in Column A that was
Selected in LISTBOX2, AND
3. The Value populated into LISTBOX3 is = the Value Placed into TEXTBOX1, and
4. The Numerical Value populated into LISTBOX3 is NOT StrikeThrough.

Currently the BELOW code works GREAT, BUT it ONLY lists the Numerical Values in 1(ONE) Section of
DATA in Relation to the ID Value in Column A(615)

Is there a NEXT/LOOP Line or similar that will ADD ALL other Conditional Values that have the
Conditions Met?
There is About 200 Column A values, EACH with its Data in the Above Layout.
I need to include these Values also to populate in the Listbox3 too.


Private Sub TextBox1_Change()
Application.ScreenUpdating = False
ListBox3.Clear
If TextBox1.Value < "" Then

Dim LastCell As Long
Dim myrow As Long
Dim i As Long
On Error Resume Next
LastCell = Worksheets("InspectionData").Cells(Rows.Count, "A").End(xlUp).Row

With ActiveWorkbook.Worksheets("InspectionData")
For myrow = 1 To LastCell
If .Cells(myrow, 1) < "" And .Cells(myrow, 1).Offset(-1, 2).Value = ListBox1.Value And
_
.Cells(myrow, 1).Offset(-1, 6).Value = ListBox2.Value Then
For i = 2 To 22
If .Cells(myrow, 3).Offset(i, 0).Font.Strikethrough = False And Cells(myrow, 3).Offset(i,
0).Value < "" _
And IsNumeric(.Cells(myrow, 3).Offset(i, 0)) Then
If .Cells(myrow, 3).Value = TextBox1.Value Then
ListBox3.AddItem Cells(myrow, 3).Offset(i, 0)
ListBox3.List(ListBox3.ListCount - 1, 1) = Cells(myrow, 3).Offset(i, 0).Address
End If

End If
Next i
End If
Next
End With

End If
Application.ScreenUpdating = True
End Sub


Corey....


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 363
Default Do i need a Next or Loop statement ?

Got a Bit furhter after the 1st post.
Now i ONLY need to eliminate ALL Numerical Values that are LESS(<) Textbox1.value:

Private Sub TextBox1_Change()
Application.ScreenUpdating = False
ListBox3.Clear
If TextBox1.Value < "" Then

Dim LastCell As Long
Dim myrow As Long
Dim i As Long
On Error Resume Next
LastCell = Worksheets("InspectionData").Cells(Rows.Count, "A").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
For myrow = 1 To LastCell
If .Cells(myrow, 1) < "" And .Cells(myrow, 1).Offset(-1, 2).Value = ListBox1.Value And
_
.Cells(myrow, 1).Offset(-1, 6).Value = ListBox2.Value Then
For i = 2 To 22
If .Cells(myrow, 3).Offset(i, 0).Font.Strikethrough = False And Cells(myrow, 3).Offset(i,
0).Value < "" _
And IsNumeric(.Cells(myrow, 3).Offset(i, 0)) Then 'And .Cells(myrow, 3).Offset(i, 0).Value
TextBox1.Value Then
ListBox3.AddItem Cells(myrow, 3).Offset(i, 0)
ListBox3.List(ListBox3.ListCount - 1, 1) = Cells(myrow, 3).Offset(i, 0).Address
End If
Next i
End If
Next
End With

End If
Application.ScreenUpdating = True
End Sub





"Corey" wrote in message ...
The following code is part of a Userform to FIND Certain Values, provided there are Conditions Met.
The Data layout is:

A B C D E F G
1 FRED BLUE
2 615
3 25
4 31
5 87
6 7
7 60
8 75 <=== STRIKE THROUGH
9 20
10
11
12
13
14
15
16
17
18
19
20 JACK RED
21 614
22

etc.............


Therefore,
As i am LOOKING for a Numerical Value in Column C that,
1. Has a MATCHING value in Column C that is .Offset(-1, 2) from the ID Value in Column A that was
Selected in LISTBOX1, AND
2. Has a MATCHING value in Column G that is .Offset(-1, 6) from the ID Value in Column A that was
Selected in LISTBOX2, AND
3. The Value populated into LISTBOX3 is = the Value Placed into TEXTBOX1, and
4. The Numerical Value populated into LISTBOX3 is NOT StrikeThrough.

Currently the BELOW code works GREAT, BUT it ONLY lists the Numerical Values in 1(ONE) Section of
DATA in Relation to the ID Value in Column A(615)

Is there a NEXT/LOOP Line or similar that will ADD ALL other Conditional Values that have the
Conditions Met?
There is About 200 Column A values, EACH with its Data in the Above Layout.
I need to include these Values also to populate in the Listbox3 too.


Private Sub TextBox1_Change()
Application.ScreenUpdating = False
ListBox3.Clear
If TextBox1.Value < "" Then

Dim LastCell As Long
Dim myrow As Long
Dim i As Long
On Error Resume Next
LastCell = Worksheets("InspectionData").Cells(Rows.Count, "A").End(xlUp).Row

With ActiveWorkbook.Worksheets("InspectionData")
For myrow = 1 To LastCell
If .Cells(myrow, 1) < "" And .Cells(myrow, 1).Offset(-1, 2).Value = ListBox1.Value And
_
.Cells(myrow, 1).Offset(-1, 6).Value = ListBox2.Value Then
For i = 2 To 22
If .Cells(myrow, 3).Offset(i, 0).Font.Strikethrough = False And Cells(myrow, 3).Offset(i,
0).Value < "" _
And IsNumeric(.Cells(myrow, 3).Offset(i, 0)) Then
If .Cells(myrow, 3).Value = TextBox1.Value Then
ListBox3.AddItem Cells(myrow, 3).Offset(i, 0)
ListBox3.List(ListBox3.ListCount - 1, 1) = Cells(myrow, 3).Offset(i, 0).Address
End If

End If
Next i
End If
Next
End With

End If
Application.ScreenUpdating = True
End Sub


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
for loop with if statement Steve Excel Worksheet Functions 1 February 17th 10 07:56 PM
loop Statement Nigel Excel Programming 0 April 4th 06 04:10 PM
If statement - Loop? George Excel Discussion (Misc queries) 1 March 14th 06 07:06 AM
Help with a loop VBA with an if statement kixelsid Excel Programming 10 February 28th 06 07:15 PM
Do Until loop with if statement Sandy[_3_] Excel Programming 4 July 17th 03 11:06 AM


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