ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Incrementing numbers (https://www.excelbanter.com/excel-programming/397029-incrementing-numbers.html)

[email protected]

Incrementing numbers
 
Hello,

Can someone please provide some code that will look at each cell in a
column to ascertain if the number in each cell is incrementing by 1. I
would also like it to highlite the first cell in every non
incrementing sequence. Hope this is clear ;-)

Chalky


Jayson Wiser

Incrementing numbers
 
Sub test_increments()
For each cell in
range(range("A1").offset(1,0),range("A65536").end( xlup))
if cell.value < cell.offset(-1,0).value + 1 then
'highlight cell
end if
next cell
end sub

wrote in message
ps.com...
Hello,

Can someone please provide some code that will look at each cell in a
column to ascertain if the number in each cell is incrementing by 1. I
would also like it to highlite the first cell in every non
incrementing sequence. Hope this is clear ;-)

Chalky




[email protected]

Incrementing numbers
 
On Sep 7, 11:41 am, "Jayson Wiser"
wrote:
Sub test_increments()
For each cell in
range(range("A1").offset(1,0),range("A65536").end( xlup))
if cell.value < cell.offset(-1,0).value + 1 then
'highlight cell
end if
next cell
end sub

wrote in message

ps.com...



Hello,


Can someone please provide some code that will look at each cell in a
column to ascertain if the number in each cell is incrementing by 1. I
would also like it to highlite the first cell in every non
incrementing sequence. Hope this is clear ;-)


Chalky- Hide quoted text -


- Show quoted text -


Thanks for the checking code. Anybody able to assist with the
highlighting bit?


Viquar[_2_]

Incrementing numbers
 
Why don't you simply use conditional formatting?

Select one cell in the range. Go to Format -- Conditional Format--
Select Formula IS from the dropdown.


Suppose the cell you've selected is A4

in the textbox write
=(A4-A3)1

Select the formatting of your choice, including font colour and
highlight colour.

Copy the cell and paste it across the entire range -- Paste special --
formats.


HTH


Mike H

Incrementing numbers
 
or the highlighting use

Sub test_increments()
For Each cell In Range(Range("A1").Offset(1, 0),
Range("A65536").End(xlUp))
If cell.Value < cell.Offset(-1, 0).Value + 1 Then
cell.Interior.ColorIndex = 3
End If
Next cell
End Sub

Mike

" wrote:

On Sep 7, 11:41 am, "Jayson Wiser"
wrote:
Sub test_increments()
For each cell in
range(range("A1").offset(1,0),range("A65536").end( xlup))
if cell.value < cell.offset(-1,0).value + 1 then
'highlight cell
end if
next cell
end sub

wrote in message

ps.com...



Hello,


Can someone please provide some code that will look at each cell in a
column to ascertain if the number in each cell is incrementing by 1. I
would also like it to highlite the first cell in every non
incrementing sequence. Hope this is clear ;-)


Chalky- Hide quoted text -


- Show quoted text -


Thanks for the checking code. Anybody able to assist with the
highlighting bit?



[email protected]

Incrementing numbers
 
On Sep 7, 4:10 pm, Mike H wrote:
or the highlighting use

Sub test_increments()
For Each cell In Range(Range("A1").Offset(1, 0),
Range("A65536").End(xlUp))
If cell.Value < cell.Offset(-1, 0).Value + 1 Then
cell.Interior.ColorIndex = 3
End If
Next cell
End Sub

Mike



" wrote:
On Sep 7, 11:41 am, "Jayson Wiser"
wrote:
Sub test_increments()
For each cell in
range(range("A1").offset(1,0),range("A65536").end( xlup))
if cell.value < cell.offset(-1,0).value + 1 then
'highlight cell
end if
next cell
end sub


wrote in message


ups.com...


Hello,


Can someone please provide some code that will look at each cell in a
column to ascertain if the number in each cell is incrementing by 1. I
would also like it to highlite the first cell in every non
incrementing sequence. Hope this is clear ;-)


Chalky- Hide quoted text -


- Show quoted text -


Thanks for the checking code. Anybody able to assist with the
highlighting bit?- Hide quoted text -


- Show quoted text -


Thanks, this suits my needs exactly



All times are GMT +1. The time now is 01:33 AM.

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