PC Review


Reply
Thread Tools Rate Thread

How do I make my macro update each month?

 
 
=?Utf-8?B?TWFjcm9MZWFybmluZw==?=
Guest
Posts: n/a
 
      22nd Nov 2006
I have a spreadsheet that is updated monthly.

There is one column per month.

How do I create a macro that will insert the numbers in the correct column.

For example, once the September is filled in, I now want to fill in the
October column.

Any suggestions?
 
Reply With Quote
 
 
 
 
zz
Guest
Posts: n/a
 
      22nd Nov 2006
Create generic function that act based on a named range
then in the new column you name the range you process with the current month

in the generic functions change the last month with the new month.


Dissecting:



you have a certain function that processs data in range "A:A",


this is your function


process_month(month as range) as integer


then you pass the "month" argument of the type range to be processed by the
function


in your sheet .


select column "A:A" , name to "January"


then column "B:B" will be "february",


column "C:C" would be "March".. and so on.



then in you formula you would pass the argument as follows

my_var = process_month("january")

when the month changes, you only have to replace the "month" argument in
your formula


it is also more flexible if you store the name of the current month in
somewhere into your sheet.

example:


instead of replacing the "month" argument in your code you store the
current month name into a cell outside from the limits of your data , like
AK100 or so



then your generic formula would be like this



my_var = process_month(activesheet.range("ak100").value)





--
---
zz [MX]
cuasi-musico,semi-poeta y loco


"MacroLearning" <(E-Mail Removed)> wrote in message
news:595D3B07-46B4-4480-A808-(E-Mail Removed)...
>I have a spreadsheet that is updated monthly.
>
> There is one column per month.
>
> How do I create a macro that will insert the numbers in the correct
> column.
>
> For example, once the September is filled in, I now want to fill in the
> October column.
>
> Any suggestions?



 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      22nd Nov 2006
Assuming you have the month names in row 1 in columns 1 to 12 then
Sub BuildCalendar()
Dim dt As Date
Dim cell As Range
Dim last As Long, i As Long
Range("A2").Resize(31, 12).ClearContents
For Each cell In Range("A1:L1")
dt = DateValue(cell.Value & " 1, " & Year(Date))
last = Day(DateSerial(Year(dt), Month(dt) + 1, 0))
For i = 1 To last
cell.Offset(i, 0) = i
Next
Next
End Sub

If that isn't exactly what you want, maybe you can see the pieces you need
from within it.

--
Regards,
Tom Ogilvy


"MacroLearning" wrote:

> I have a spreadsheet that is updated monthly.
>
> There is one column per month.
>
> How do I create a macro that will insert the numbers in the correct column.
>
> For example, once the September is filled in, I now want to fill in the
> October column.
>
> Any suggestions?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro to calculate or make/update formula jat Microsoft Excel Programming 1 21st Feb 2010 05:28 AM
How do I make the month display on the month view on MS Outlook 20 Randy Microsoft Outlook Discussion 1 20th Aug 2009 08:53 PM
excel to make the days cary over month to month automaticly GARY Microsoft Excel New Users 1 19th Apr 2008 06:05 PM
How to make loop month by month ? Microsoft VB .NET 3 28th Jan 2007 10:35 AM
Update Query - daily update of 31 fields (each day of month) =?Utf-8?B?RnJhbmsgRi4=?= Microsoft Access Queries 2 15th Dec 2004 01:25 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:29 PM.