ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why it doesn't work (https://www.excelbanter.com/excel-programming/372846-why-doesnt-work.html)

François

Why it doesn't work
 
Hi,

Why this code stop always at the last not empty line (7269). The data is at
line 6839. Any tought.

Dim Line As Integer

For u = 2 To .Range("A65536").End(xlUp).Row
If .Cells(u, 1) = Me.Combo1.Text And .Cells(u, 2) = Me.Combo2.Text And
..Cells(u, 3) = Me.Combo3.Text And .Cells(u, 4) = Me.Combo4.Text Then
Line = u
Exit Sub
End If
Next

Thanks



Dave Peterson

Why it doesn't work
 
Maybe there's a difference between what's in the comboboxes and what's in those
cells--upper/lower case differences, spelling differences, differences in
spaces????

"François" wrote:

Hi,

Why this code stop always at the last not empty line (7269). The data is at
line 6839. Any tought.

Dim Line As Integer

For u = 2 To .Range("A65536").End(xlUp).Row
If .Cells(u, 1) = Me.Combo1.Text And .Cells(u, 2) = Me.Combo2.Text And
.Cells(u, 3) = Me.Combo3.Text And .Cells(u, 4) = Me.Combo4.Text Then
Line = u
Exit Sub
End If
Next

Thanks


--

Dave Peterson

François

Why it doesn't work
 
No differences, the datas in the comboboxes are the same than de cells.

Thanks for you help.


"Dave Peterson" a écrit dans le message de news:
...
Maybe there's a difference between what's in the comboboxes and what's in
those
cells--upper/lower case differences, spelling differences, differences in
spaces????

"François" wrote:

Hi,

Why this code stop always at the last not empty line (7269). The data is
at
line 6839. Any tought.

Dim Line As Integer

For u = 2 To .Range("A65536").End(xlUp).Row
If .Cells(u, 1) = Me.Combo1.Text And .Cells(u, 2) = Me.Combo2.Text And
.Cells(u, 3) = Me.Combo3.Text And .Cells(u, 4) = Me.Combo4.Text Then
Line = u
Exit Sub
End If
Next

Thanks


--

Dave Peterson




Dave Peterson

Why it doesn't work
 
Add some debug.print lines to verify--I bet there's a difference.

debug.print .cells(u,1).value & vblf & me.combo1.text

then look for the differences in the immediate window.



"François" wrote:

No differences, the datas in the comboboxes are the same than de cells.

Thanks for you help.

"Dave Peterson" a écrit dans le message de news:
...
Maybe there's a difference between what's in the comboboxes and what's in
those
cells--upper/lower case differences, spelling differences, differences in
spaces????

"François" wrote:

Hi,

Why this code stop always at the last not empty line (7269). The data is
at
line 6839. Any tought.

Dim Line As Integer

For u = 2 To .Range("A65536").End(xlUp).Row
If .Cells(u, 1) = Me.Combo1.Text And .Cells(u, 2) = Me.Combo2.Text And
.Cells(u, 3) = Me.Combo3.Text And .Cells(u, 4) = Me.Combo4.Text Then
Line = u
Exit Sub
End If
Next

Thanks


--

Dave Peterson


--

Dave Peterson

François

Why it doesn't work
 
Here what I have :

Private Sub CmdOK_Click()
Dim Line As Integer
Dim u As Integer

With Sheets("Inventory")

For u = 2 To .Range("A65536").End(xlUp).Row
If .Cells(u, 1) = Me.Combo1.Text Then
Debug.Print .Cells(u, 1).Value & vbLf & Me.Combo1.Text 'u =7414, Combo1
= w
If .Cells(u, 2) = Me.Combo2.Text Then
Debug.Print .Cells(u, 1).Value & vbLf & Me.Combo1.Text 'u =7414, Combo2
= x
If .Cells(u, 3) = Me.Combo3.Text Then
Debug.Print .Cells(u, 1).Value & vbLf & Me.Combo1.Text 'u =7414, Combo3
= y
If .Cells(u, 4) = Me.Combo4.Text Then
Debug.Print .Cells(u, 1).Value & vbLf & Me.Combo1.Text 'u =7414, Combo4
= z
Line = u
Exit Sub
End If
End If
End If
End If
Next

"Dave Peterson" a écrit dans le message de news:
...
Add some debug.print lines to verify--I bet there's a difference.

debug.print .cells(u,1).value & vblf & me.combo1.text

then look for the differences in the immediate window.



"François" wrote:

No differences, the datas in the comboboxes are the same than de cells.

Thanks for you help.

"Dave Peterson" a écrit dans le message de
news:
...
Maybe there's a difference between what's in the comboboxes and what's
in
those
cells--upper/lower case differences, spelling differences, differences
in
spaces????

"François" wrote:

Hi,

Why this code stop always at the last not empty line (7269). The data
is
at
line 6839. Any tought.

Dim Line As Integer

For u = 2 To .Range("A65536").End(xlUp).Row
If .Cells(u, 1) = Me.Combo1.Text And .Cells(u, 2) = Me.Combo2.Text And
.Cells(u, 3) = Me.Combo3.Text And .Cells(u, 4) = Me.Combo4.Text Then
Line = u
Exit Sub
End If
Next

Thanks

--

Dave Peterson


--

Dave Peterson




Dave Peterson

Why it doesn't work
 
I think I would have used all the fields:

for u = 2 to ....
Debug.print "==========" & u & "===="
Debug.Print "1: " & .Cells(u, 1).Value & "|" & Me.Combo1.Text
Debug.Print "2: " & .Cells(u, 2).Value & "|" & Me.Combo2.Text
Debug.Print "3: " & .Cells(u, 3).Value & "|" & Me.Combo3.Text
Debug.Print "4: " & .Cells(u, 4).Value & "|" & Me.Combo4.Text
Debug.Print "=============="
'and comment out the other stuff
next u

And if you know a row that is exactly the same start the

for u = 2342 to 2345 'say


"François" wrote:

Here what I have :

Private Sub CmdOK_Click()
Dim Line As Integer
Dim u As Integer

With Sheets("Inventory")

For u = 2 To .Range("A65536").End(xlUp).Row
If .Cells(u, 1) = Me.Combo1.Text Then
Debug.Print .Cells(u, 1).Value & vbLf & Me.Combo1.Text 'u =7414, Combo1
= w
If .Cells(u, 2) = Me.Combo2.Text Then
Debug.Print .Cells(u, 1).Value & vbLf & Me.Combo1.Text 'u =7414, Combo2
= x
If .Cells(u, 3) = Me.Combo3.Text Then
Debug.Print .Cells(u, 1).Value & vbLf & Me.Combo1.Text 'u =7414, Combo3
= y
If .Cells(u, 4) = Me.Combo4.Text Then
Debug.Print .Cells(u, 1).Value & vbLf & Me.Combo1.Text 'u =7414, Combo4
= z
Line = u
Exit Sub
End If
End If
End If
End If
Next

"Dave Peterson" a écrit dans le message de news:
...
Add some debug.print lines to verify--I bet there's a difference.

debug.print .cells(u,1).value & vblf & me.combo1.text

then look for the differences in the immediate window.



"François" wrote:

No differences, the datas in the comboboxes are the same than de cells.

Thanks for you help.

"Dave Peterson" a écrit dans le message de
news:
...
Maybe there's a difference between what's in the comboboxes and what's
in
those
cells--upper/lower case differences, spelling differences, differences
in
spaces????

"François" wrote:

Hi,

Why this code stop always at the last not empty line (7269). The data
is
at
line 6839. Any tought.

Dim Line As Integer

For u = 2 To .Range("A65536").End(xlUp).Row
If .Cells(u, 1) = Me.Combo1.Text And .Cells(u, 2) = Me.Combo2.Text And
.Cells(u, 3) = Me.Combo3.Text And .Cells(u, 4) = Me.Combo4.Text Then
Line = u
Exit Sub
End If
Next

Thanks

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 12:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com