Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Macro for a comparison

Hello,

I would like the code for the following:

Compare the numbers in column I to column J (column I will always be a
bigger number). Display the result in column K in a percentage off high
(meaning column I) Its ok to display like: -7, no need to put the % sign.

example 49.35 is column I, 47 is column J column K should read -5, meaning
47 is 5% away from 49.35 and just display it as -5

Thanks in advance
--
Mike B
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Macro for a comparison

You can do this easily just with standard calculations in column K; e.g. (for
K1):
= (I1-J1)/J1 (formatted properly, would give %)
= 100*(I1-J1)/J1 gives the number in the format you mention


"mike b" wrote:

Hello,

I would like the code for the following:

Compare the numbers in column I to column J (column I will always be a
bigger number). Display the result in column K in a percentage off high
(meaning column I) Its ok to display like: -7, no need to put the % sign.

example 49.35 is column I, 47 is column J column K should read -5, meaning
47 is 5% away from 49.35 and just display it as -5

Thanks in advance
--
Mike B

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Macro for a comparison

How can I get this to go thru the 800+ lines of data? asutomatically?
I want it to do this with a macro and the amount of lines of data changes,
the data can be large so I dont want it limited until there is no more data
Thanks
Mike

"K Dales" wrote:

You can do this easily just with standard calculations in column K; e.g. (for
K1):
= (I1-J1)/J1 (formatted properly, would give %)
= 100*(I1-J1)/J1 gives the number in the format you mention


"mike b" wrote:

Hello,

I would like the code for the following:

Compare the numbers in column I to column J (column I will always be a
bigger number). Display the result in column K in a percentage off high
(meaning column I) Its ok to display like: -7, no need to put the % sign.

example 49.35 is column I, 47 is column J column K should read -5, meaning
47 is 5% away from 49.35 and just display it as -5

Thanks in advance
--
Mike B

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Macro for a comparison

You could just enter the formula as given and drag it down to the botton of
your data but if you REALLY want a macro to do it then try:

Sub InsCalc()
Dim endRow As Long
endRow = Cells(Rows.Count, 9).End(xlUp).row
With Range(Cells(2, 11), Cells(endRow, 11))
.FormulaR1C1 = "=-100*(RC[-2]-RC[-1])/RC[-1]"
.NumberFormat = "0"
End With
End Sub

Regards
Rowan

"mike b" wrote:

How can I get this to go thru the 800+ lines of data? asutomatically?
I want it to do this with a macro and the amount of lines of data changes,
the data can be large so I dont want it limited until there is no more data
Thanks
Mike

"K Dales" wrote:

You can do this easily just with standard calculations in column K; e.g. (for
K1):
= (I1-J1)/J1 (formatted properly, would give %)
= 100*(I1-J1)/J1 gives the number in the format you mention


"mike b" wrote:

Hello,

I would like the code for the following:

Compare the numbers in column I to column J (column I will always be a
bigger number). Display the result in column K in a percentage off high
(meaning column I) Its ok to display like: -7, no need to put the % sign.

example 49.35 is column I, 47 is column J column K should read -5, meaning
47 is 5% away from 49.35 and just display it as -5

Thanks in advance
--
Mike B

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
row comparison Jim Excel Worksheet Functions 4 August 21st 07 10:20 PM
Price Comparison Macro - This Is For An Excel MVP Mr. Smiley Excel Discussion (Misc queries) 5 August 30th 05 05:21 PM
Comparison chartasap Excel Worksheet Functions 2 July 19th 05 02:09 PM
HELP 2sht comparison MACRO Les Wegg Excel Discussion (Misc queries) 1 May 12th 05 09:32 AM
Comparison mike Excel Programming 2 February 2nd 04 09:10 PM


All times are GMT +1. The time now is 01:11 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"