Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Comparing cell values

How do I use VBA to compare data in two cells to return
something. Eg. Column B has numbers,but no zero values,
and Column C has numbers but can contain blank cells.
How do I write code to say if it has numbers in Column C
then to do a calculation that says if column C - Column B
< + 1 or - 1, then in column D type "Within Range"
else "out of range".
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Comparing cell values

Hi there,
Try entering this formula in column D:-

= IF(AND(ISNUMBER(B1),ISNUMBER(C1)),IF(OR(C1-B1 1,C1-B1
< -1),"Out of Range","In Range"),"Not both Numbers")

My guess is you wanted numbers that are within +/- 1 of
each other.

-----Original Message-----
How do I use VBA to compare data in two cells to return
something. Eg. Column B has numbers,but no zero values,
and Column C has numbers but can contain blank cells.
How do I write code to say if it has numbers in Column C
then to do a calculation that says if column C - Column

B
< + 1 or - 1, then in column D type "Within Range"
else "out of range".
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Comparing cell values

Excellent!!

How do I write VBA to input that formula in Column D and
filter down to the end of the data that exists in column B?

-----Original Message-----
Hi there,
Try entering this formula in column D:-

= IF(AND(ISNUMBER(B1),ISNUMBER(C1)),IF(OR(C1-B1 1,C1-B1
< -1),"Out of Range","In Range"),"Not both Numbers")

My guess is you wanted numbers that are within +/- 1 of
each other.

-----Original Message-----
How do I use VBA to compare data in two cells to return
something. Eg. Column B has numbers,but no zero values,
and Column C has numbers but can contain blank cells.
How do I write code to say if it has numbers in Column C
then to do a calculation that says if column C - Column

B
< + 1 or - 1, then in column D type "Within Range"
else "out of range".
.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Comparing cell values

1. Generally users just drag the formula - grab the
little black box on the bottom right of the cell & drag.
The column/row refs change automatically.
2. To enter a formula in VBA just make the cell contain
the formula e.g.

Activesheet.cells(<row,<col) = "=IF( etc ...)"

You'll probably want to put this in a while loop -
something like :-

RowCnt = 1

While ActiveSheet.Cells(RowCnt,2) < ""
<Add the formula
RowCnt = RowCnt + 1
Wend

3. You could do it all in VBA - Lookup the while and if
statements in the VBA help. If you really are wanting to
do it all in VBA then it's probably best not to bother
with the formula - just do the if and populate column "D"
directly.

Good Luck!
-----Original Message-----
Excellent!!

How do I write VBA to input that formula in Column D and
filter down to the end of the data that exists in column

B?

-----Original Message-----
Hi there,
Try entering this formula in column D:-

= IF(AND(ISNUMBER(B1),ISNUMBER(C1)),IF(OR(C1-B1 1,C1-

B1
< -1),"Out of Range","In Range"),"Not both Numbers")

My guess is you wanted numbers that are within +/- 1 of
each other.

-----Original Message-----
How do I use VBA to compare data in two cells to

return
something. Eg. Column B has numbers,but no zero

values,
and Column C has numbers but can contain blank cells.
How do I write code to say if it has numbers in Column

C
then to do a calculation that says if column C -

Column
B
< + 1 or - 1, then in column D type "Within Range"
else "out of range".
.

.

.

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
Conditional Formatting: comparing cell values Coco212 Excel Worksheet Functions 0 April 1st 10 09:44 PM
Question about comparing 2 cell values mCassidy Excel Discussion (Misc queries) 3 May 16th 07 09:37 PM
Comparing multiple cell values scoobydoo2006 Excel Discussion (Misc queries) 0 June 13th 06 04:58 PM
Comparing cell values then labeling them based on comparision Andrew Excel Discussion (Misc queries) 1 September 13th 05 11:11 PM
Counting values and comparing them to a single cell Tbentsen Excel Discussion (Misc queries) 3 August 4th 05 10:47 PM


All times are GMT +1. The time now is 03:35 AM.

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"