Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default how to compare the active cell value to the previous cell's value

I have a list of about 55,000 entries in Column A. Though sorted by value,
the values change at various/random times. I need to determine, in a macro,
when the value changes so that I can take action to do something else. So,
how can I say:

If ActiveCell.Value < (the value of the cell directly above it) Then
takeaction

In other words, I don't know how to refer to the cell directly above the
current cell. It can't be the exact address because there are thousands of
different address. Maybe it has something to do with ActiveCell.Offset(-1,
0) but I don't think that's quite it.

Thanks. Dan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default how to compare the active cell value to the previous cell's value

ActiveCell.Offset(-1, 0).Value - is correct to get the value above the
active cell. Try it.

If ActiveCell.value < ActiveCell.Offset(-1,0).Value then
'take action
End If

you might want to put this in the worksheet change event to detect changes
in column A something like....

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
If ActiveCell.Value < ActiveCell.Offset(-1, 0).Value Then
MsgBox "Do something"
End If
End If
End Sub

--
Cheers
Nigel



"crimsonkng" wrote in message
...
I have a list of about 55,000 entries in Column A. Though sorted by

value,
the values change at various/random times. I need to determine, in a

macro,
when the value changes so that I can take action to do something else.

So,
how can I say:

If ActiveCell.Value < (the value of the cell directly above it) Then
takeaction

In other words, I don't know how to refer to the cell directly above the
current cell. It can't be the exact address because there are thousands

of
different address. Maybe it has something to do with

ActiveCell.Offset(-1,
0) but I don't think that's quite it.

Thanks. Dan




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default how to compare the active cell value to the previous cell's value

Thanks, guys.

I tried Nigel's and it worked, for the most part (my data was a little
wierd). I like to learn things so I'll try Norman's suggestion later.

Thanks for taking the time to reply and solving this.

Dan
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 value in current cell to previous cell Bob Aloisi Excel Worksheet Functions 6 January 25th 08 02:29 PM
Repeat: Active Cell's Address Milind Excel Programming 2 September 30th 05 01:47 AM
Remember a previous cell's value Goody Excel Worksheet Functions 5 March 24th 05 08:45 PM
Previous active cell MVM Excel Programming 3 January 2nd 05 10:29 PM
Get a cell's previous value Rick[_25_] Excel Programming 1 April 19th 04 08:36 PM


All times are GMT +1. The time now is 09:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"