Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Loop Down Columns and Compare Values

Hi,

I am trying to write a macro that will loop through columns (eg A and
B) and across the row and compare the values on the same row in
different columns and if the value in column A on that same row is
greater then I would like to highlight those cells. Is there anyone who
could help?

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Loop Down Columns and Compare Values

set rng = Range("A1:A100")
rng.Resize(,2).Interior.ColorIndex = xlNone
for each cell in rng
if cell.Value cell.offset(0,1).Value then
cell.Resize(1,2).Interior.ColorIndex = 3
end if
Next

--
regards,
Tom Ogilvy

"DrwRob28" wrote in message
ups.com...
Hi,

I am trying to write a macro that will loop through columns (eg A and
B) and across the row and compare the values on the same row in
different columns and if the value in column A on that same row is
greater then I would like to highlight those cells. Is there anyone who
could help?

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Loop Down Columns and Compare Values

Thanks Tom!\


Tom Ogilvy wrote:
set rng = Range("A1:A100")
rng.Resize(,2).Interior.ColorIndex = xlNone
for each cell in rng
if cell.Value cell.offset(0,1).Value then
cell.Resize(1,2).Interior.ColorIndex = 3
end if
Next

--
regards,
Tom Ogilvy

"DrwRob28" wrote in message
ups.com...
Hi,

I am trying to write a macro that will loop through columns (eg A and
B) and across the row and compare the values on the same row in
different columns and if the value in column A on that same row is
greater then I would like to highlight those cells. Is there anyone who
could help?

Thanks!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Loop Down Columns and Compare Values

Thanks Tom!\


Tom Ogilvy wrote:
set rng = Range("A1:A100")
rng.Resize(,2).Interior.ColorIndex = xlNone
for each cell in rng
if cell.Value cell.offset(0,1).Value then
cell.Resize(1,2).Interior.ColorIndex = 3
end if
Next

--
regards,
Tom Ogilvy

"DrwRob28" wrote in message
ups.com...
Hi,

I am trying to write a macro that will loop through columns (eg A and
B) and across the row and compare the values on the same row in
different columns and if the value in column A on that same row is
greater then I would like to highlight those cells. Is there anyone who
could help?

Thanks!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Loop Down Columns and Compare Values

Tom,

Do you know how I can get it to skip to columns C and D, E and F,
etc.after it is doen with A and B?

Thanks,
Drew

DrwRob28 wrote:
Thanks Tom!\


Tom Ogilvy wrote:
set rng = Range("A1:A100")
rng.Resize(,2).Interior.ColorIndex = xlNone
for each cell in rng
if cell.Value cell.offset(0,1).Value then
cell.Resize(1,2).Interior.ColorIndex = 3
end if
Next

--
regards,
Tom Ogilvy

"DrwRob28" wrote in message
ups.com...
Hi,

I am trying to write a macro that will loop through columns (eg A and
B) and across the row and compare the values on the same row in
different columns and if the value in column A on that same row is
greater then I would like to highlight those cells. Is there anyone who
could help?

Thanks!




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Loop Down Columns and Compare Values

Something screwy happened and an incomplete post may have been posted. use
this post

Dim rng as Range, ar as Range
set rng = Range("A1:A100,C1:C100,E1:E100")
for each ar in rng.Areas
ar.Resize(,2).Interior.ColorIndex = xlNone
for each cell in ar
if cell.Value cell.offset(0,1).Value then
cell.Resize(1,2).Interior.ColorIndex = 3
end if
Next cell
Next ar


--
Regards,
Tom Ogilvy


"DrwRob28" wrote:

Tom,

Do you know how I can get it to skip to columns C and D, E and F,
etc.after it is doen with A and B?

Thanks,
Drew

DrwRob28 wrote:
Thanks Tom!\


Tom Ogilvy wrote:
set rng = Range("A1:A100")
rng.Resize(,2).Interior.ColorIndex = xlNone
for each cell in rng
if cell.Value cell.offset(0,1).Value then
cell.Resize(1,2).Interior.ColorIndex = 3
end if
Next

--
regards,
Tom Ogilvy

"DrwRob28" wrote in message
ups.com...
Hi,

I am trying to write a macro that will loop through columns (eg A and
B) and across the row and compare the values on the same row in
different columns and if the value in column A on that same row is
greater then I would like to highlight those cells. Is there anyone who
could help?

Thanks!



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
Compare values in different columns JJM0926 Excel Discussion (Misc queries) 2 June 27th 07 09:34 PM
I want to compare the values in two columns Dr. Darrell Excel Discussion (Misc queries) 4 September 14th 06 02:07 AM
Compare values in different columns Alan Excel Programming 2 February 21st 06 01:26 AM
Compare values in columns cpetta New Users to Excel 5 April 2nd 05 03:24 PM
Excel Compare values in columns & display missing values in a new cpetta Excel Discussion (Misc queries) 1 April 2nd 05 05:51 AM


All times are GMT +1. The time now is 01:08 PM.

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"