>From what I can see, you're looking in rows 5 to 1000
and comparing the value in column (D) to the value in cell B7.
 
If you use the debugger to step through one line at a time and watch your value 
for "q",
you'll see that the loop:
 
For q = 5 to 1000
increments q by 1 for each iteration of the loop.
(if you wanted it to do every THIRD row, you could use for q=5 to 1000 step 3)
 
that means, that it runs through with q =5,
then q=6, q=7, and so on.
 
But within your loop, you have q=q+1
 
that means that it will start with q=5,
then, q=q+1 makes q=6,
but the for q=5 to 1000 statement will then increment q to 7!
 
So, your loop is only checking q=5,7,9,11, etc.
 
if you want it to check all rows, remove the line: q = q + 1
 

Paul
-----------------------------------------
“Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can.” - John Wesley
-----------------------------------------

 From: Ashish Bhalara <ashishbhalar...@gmail.com>
>To: excel-macros@googlegroups.com 
>Sent: Monday, February 2, 2015 6:14 AM
>Subject: $$Excel-Macros$$ Loop to check duplicate value
>  
>
>
>Dear experts,
>
>
>Below code is not work to check duplicate value, please know me problem in 
>code.
>
>
>For q = 5 To 1000
>    If Worksheets("BankData").Cells(q, 4).Value = 
> Worksheets("NewEntry").Cells(7, 2).Value Then
>    MsgBox "Account number already exist", vbOKOnly, "Ashish"
>    Exit Sub
>    End If
>    q = q + 1
>    
>Next q
>
>
>
>
>Regards.
>Ashish Bhalara
>9624111822
>PPlease do not print this email unless it is absolutely necessary. Spread
environmental üawareness.♣♣♣
>
> 
-- 
>Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
>=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
>https://www.facebook.com/discussexcel
> 
>FORUM RULES
> 
>1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
>Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
>quick attention or may not be answered.
>2) Don't post a question in the thread of another member.
>3) Don't post questions regarding breaking or bypassing any security measure.
>4) Acknowledge the responses you receive, good or bad.
>5) Jobs posting is not allowed.
>6) Sharing copyrighted material and their links is not allowed.
> 
>NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
>members are not responsible for any loss.
>--- 
>You received this message because you are subscribed to the Google Groups "MS 
>EXCEL AND VBA MACROS" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to excel-macros+unsubscr...@googlegroups.com.
>To post to this group, send email to excel-macros@googlegroups.com.
>Visit this group at http://groups.google.com/group/excel-macros.
>For more options, visit https://groups.google.com/d/optout.
>
>
>    

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to