Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macros to compute Sales figures Differences between Months

I am trying to create a macro to compute the sales figures difference
between month. A1 to A12 cell contain the sales figure for Jan to Dec.
B1 cell contains the difference between the last 2 months.

So in the month of Oct, I want B1 to contain +A9-A8 i.e. the diff
between Sep and Aug after running the macro.

In the next month Nov, I want B1 to contain +A10-A9 and so on.

Anyone have any idea how I can create this macro to. Thanks for your
help in advance.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Macros to compute Sales figures Differences between Months

monthNum = Month(Date)
Range("B1").Formula = "=A" & monthNum - 1 & "-A" & monthNum - 2

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"slc" wrote in message
...
I am trying to create a macro to compute the sales figures difference
between month. A1 to A12 cell contain the sales figure for Jan to Dec.
B1 cell contains the difference between the last 2 months.

So in the month of Oct, I want B1 to contain +A9-A8 i.e. the diff
between Sep and Aug after running the macro.

In the next month Nov, I want B1 to contain +A10-A9 and so on.

Anyone have any idea how I can create this macro to. Thanks for your
help in advance.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macros to compute Sales figures Differences between Months

Thanks Bob.

One further questions. If I want to use row number instead how should
I do it. I have the following macro statement and the 3rd statement is
incorrect.

Range("A1").Select
Selection.End(xlDown).Select
RowNum = Row()
Range("B2").Formula = "=B" & RowNum & "-B" & RowNum - 1

Basically, the same thing i.e. I first go to cell A1, then goto the
last cell. get the row number of the last cell and then put the diff
b/w last cell and 2nd last cell in B1 cell.


Thanks once again.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Macros to compute Sales figures Differences between Months

Here is your code:

Sub ComputeSales()
Dim myMonth As Long

myMonth = Month(Date)

ThisWorkbook.Worksheets(2).Range("B1") = _
ThisWorkbook.Worksheets(2).Range("A" & myMonth - 2) - _
ThisWorkbook.Worksheets(2).Range("A" & myMonth - 1)

End Sub

losmac

Użytkownik "slc" napisał w wiadomo¶ci
...
I am trying to create a macro to compute the sales figures difference
between month. A1 to A12 cell contain the sales figure for Jan to Dec.
B1 cell contains the difference between the last 2 months.

So in the month of Oct, I want B1 to contain +A9-A8 i.e. the diff
between Sep and Aug after running the macro.

In the next month Nov, I want B1 to contain +A10-A9 and so on.

Anyone have any idea how I can create this macro to. Thanks for your
help in advance.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Macros to compute Sales figures Differences between Months

rowNum = Range("A1").End(xlDown).Row
Range("B2").Formula = "=B" & rowNum & "-B" & rowNum - 1

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"slc" wrote in message
...
Thanks Bob.

One further questions. If I want to use row number instead how should
I do it. I have the following macro statement and the 3rd statement is
incorrect.

Range("A1").Select
Selection.End(xlDown).Select
RowNum = Row()
Range("B2").Formula = "=B" & RowNum & "-B" & RowNum - 1

Basically, the same thing i.e. I first go to cell A1, then goto the
last cell. get the row number of the last cell and then put the diff
b/w last cell and 2nd last cell in B1 cell.


Thanks once again.



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



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
Excel 2002: How to compute average, min and max figures? Mr. Low Excel Discussion (Misc queries) 3 August 25th 08 02:30 PM
excel sales figures George A. Jululian[_2_] Excel Discussion (Misc queries) 2 November 22nd 07 04:17 PM
How do I compute for a person's age in Excel to show also months?. Ed Neri New Users to Excel 1 October 3rd 07 10:00 AM
HOw do I merge two separate months of sales figures? knewlin Excel Worksheet Functions 4 August 29th 06 09:05 PM
Splitting apart Name from Sales figures ChuckW Excel Discussion (Misc queries) 2 June 1st 05 07:18 PM


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