If Cell is 5 or more less than a cell

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
590
Office Version
  1. 2019
Platform
  1. Windows
I have a macro running and pulling in two values.



Row I and Row J have the two values.


I cases where they do not match, and Row J is more than 5less than Row I, I need to put an “X” in Row L


Thanks,
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
How about
=IF(J1< I1-5,"X","")
 
Last edited:
Upvote 0
Apologies for that, keep forgetting to spaces in the formula, but now corrected
 
Upvote 0
what about if I use variables instead?

If PendingQty < AuthQty then
Cells(x,12).value = "X"
end if

this is not registering though
 
Upvote 0
If you want VBA it's better to state that in you post.

Can you please post your entire code?
When posting code please use code tags, the # icon in the reply window
 
Upvote 0
I apologize

Code:
[FONT=Calibri][SIZE=3][COLOR=#000000]FinalRow = Cells(Rows.Count, 3).End(xlUp).Row[/COLOR][/SIZE][/FONT]

[FONT=Calibri][SIZE=3][COLOR=#000000]For x = 8 ToFinalRow[/COLOR][/SIZE][/FONT]

[FONT=Calibri][SIZE=3][COLOR=#000000]PartNumber =Cells(x, 3).Value[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]SerialID =Cells(x, 4).Value[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]QTY = Cells(x,5).Value[/COLOR][/SIZE][/FONT]

[FONT=Calibri][SIZE=3][COLOR=#000000]Result =Trim(MyScreen.getstring(13, 15, 10))[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]AuthQty =Trim(MyScreen.getstring(4, 32, 5))[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]PendingQty = Trim(MyScreen.getstring(6,21, 5))[/COLOR][/SIZE][/FONT]

[FONT=Calibri][SIZE=3][COLOR=#000000]Worksheets("Index").Select[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Cells(x, 8) =Result[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Cells(x, 9) =AuthQty[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Cells(x, 10) =PendingQty[/COLOR][/SIZE][/FONT]

[FONT=Calibri][SIZE=3][COLOR=#000000]If PendingQty < AuthQty [/COLOR][/SIZE][SIZE=3][COLOR=#000000]- 5 Then[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]Cells(x,12).Value = "X"[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]End If[/COLOR][/SIZE][/FONT]
[FONT=Calibri][SIZE=3][COLOR=#000000]NEXT X[/COLOR][/SIZE][/FONT]
 
Last edited by a moderator:
Upvote 0
What are the values of PendingQty and AuthQty, are they actual numbers or text strings
 
Upvote 0
they are being scrapped from the screen, so im guesing text, im also guessing they need to be converted to numbers, but im a little short on knowledge to do that
 
Upvote 0

Forum statistics

Threads
1,213,483
Messages
6,113,919
Members
448,533
Latest member
thietbibeboiwasaco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top