VBA For Insert Previous Month In Sheet Name On Open

Feb 28, 2007

I'd like to make a template so that when it is opened the previous month name is inserted in the sheet name. The reason I want to use previous month is that normally this report is created in the month following the month being reported. So it is opened, months are updated, then the user saves as xls. Ideally I guess sheet would not have the month on the template.

The name of the sheets are shortened months like "Dec Results Bob" and there are 8 of these.

I can tell it might start:

Private Sub Workbook_Open() (or would .xlt be the same?)

but that's about it. I made a macro of renaming sheet but that didn't really tell me if I could insert the Month there.

View 9 Replies


ADVERTISEMENT

Open File With Previous Month In Name

May 21, 2008

I have a macro that saves a workbook with the month name automatically generated in the filename with the code below (apologies for the scrappy code, but I am rather new to VBA)

ActiveWorkbook.SaveAs Filename:= _
"I: EngineeringCapacity PlanningCapacity Report CONTROLS " & Format( Date, "mmmm") & ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

In another file I want to re-open this workbook. However, the problem arises because this will not happen till the next month, in order to update the new month's workbook with the old information. Currently I am 'cheating' by modifying the code with the actual month name, like this

Workbooks.Open Filename:="I:EngineeringCapacity PlanningCapacity Report CONTROLS April.xls" I have tried to use the Dateadd function (with a -1 as the add amount) but I have failed to make it work.

View 2 Replies View Related

On Open, Insert Month Name In Cell A1

Mar 12, 2007

I had posted about updating the sheet name but I defaulted those to generic terms. I would like to see the month populate at the top of each sheet when opened, this is for a template.

Currently the title is in A1--merged with other cells to look nice.

"Sales Monthly Report - December 2006" is the title.

I guess I would default the title to "Sales Monthly Report-2007"?

I would want the On Open to insert the previous months name and year (if applicable) since I'm running this the month after the month ends so default to previous month. not every sheet in the workbook will have this just 10 out of 12 sheets.

View 9 Replies View Related

Last Day Of Previous Month

Apr 24, 2007

I have an excel document which I am trying to automate using VBA. I have two headings which have the same text every month but the month value must change.

Basically I’m looking for the last day of the previous month. So if it was 05th April 2007 I want to return 28 March 2007. I just need to obtain the last day of the previous month in the following format ’28 March 2007’.

View 4 Replies View Related

Insert All Dates For A Month Weekly When User Inputs Month And Year?

Jul 10, 2014

I have created a time sheet in excel (see attached) that will be part of the larger workbook that will be linked with other sheets to auto fill in most fields. I am wondering if there is a way for an user to enter a Month and a Year at the top of the page and that in turn automatically fills in the days of the month by week.

So in attached sheet there are 5 boxes representing 5 weeks in a month. So if we used May 2014 as an example I would like to know if there is a way that once May 2014 is entered in up to top that. Excel fills in the dates in Week #1 with under Thursday showing 1st, under Friday showing 2nd as on for the entire month...

So as the month go by all user has to do is state the month and year and excel fills in the weekly dates for each day in month.

Attached File : Time and Attendance.xlsx‎

View 2 Replies View Related

Previous Month Formula

Feb 19, 2008

I have a month number in H2 (1-12). I want a formula that will give me the previous month number. So, if h2 = 1. I need my formula cell to equal 12.

View 9 Replies View Related

Formula To Display The Last Day Of The Previous Month

Jan 22, 2010

I am using the following formula to show the first day of previous 6 month cycle.

=DATE(YEAR(TODAY()),MONTH(TODAY())-6,1)

That formula would display: 07/01/2009

I want to have another formula show the last day of the previous month.

Basically it would display: 12/31/2009

View 6 Replies View Related

Highlight Date If Previous Month

Mar 13, 2008

Need to be able to highligh data within a range where the date in a column is for the previous month/s- therefore need to be able to also include in macro entering the current month - don't want to have to edit macro each month

View 2 Replies View Related

Last Business Day Of Prior/Previous Month

Jun 12, 2008

what formula should I use to refer to the last working day on the prioir month. I have trie to look up forums but no result os yet.

View 4 Replies View Related

Calculation That Uses Number Of Days Of Previous Month?

Jul 1, 2014

I have to do a calculation that uses the number of days of the previous month. Thought this would work but it doesn't.

[Code].....

View 12 Replies View Related

Auto Calculate End Date Of Previous Month

Jan 28, 2009

I have a cell in which I will input the last day of a month (e.g., 1/31/09, 2/28/09, etc.) In another cell, I want Excel to show the last day of the previous month. Is there a formula to calculate this automatically?

I enter in Cell 1: 1/31/09
Excel calculates in Cell 2: 12/28/08

I enter in Cell 1: 2/28/09
Excel calculates in Cell 2: 1/31/09

View 2 Replies View Related

Display Previous Month Text From A Named Range

Nov 30, 2009

Attached is an example of what I'm looking for. Example: Column A has all the month names with a defined named range of crnt. D6 has a data validation display with a value of Nov 09, I need E6 to display Oct 09 automatically from the data in Column A. Basically I need cell E6 to always display the previous months text based off cell D6. I think the example sheet explains it better.

View 2 Replies View Related

VBA Code To Return Previous Friday And Month Before Date

May 8, 2014

How to write a VBA code so that it would calculate the date of the previous Friday and from there Return the date exactly 1 month before; on any given day.

For example...
today is may 8th

So if I run the code the dates returned for last friday should be 05/02/2014
and 04/04/2014 should be returned AS the DATE exactly a month from 05/02/2014

View 6 Replies View Related

Insert Next Row Based On Previous Cell Value

Jul 15, 2004

My current code works, but there's got to be a shorter version to insert rows based on a cell value. Currently my code works on a series of If statements. If the value in the current cell is "2" then goto the next row and insert one line. If the value is "3" then go to the next row, insert, next row insert etc. I'm currently written up to a value of 10, but the coding is getting longer and longer. Anybody got a shorter loop that I could use.

View 9 Replies View Related

Formula For Working Out And Populating Table Using Previous Month Totals?

Jun 24, 2014

I have an issue whereby I have thousands of lines of data. I need to bring back the "previous month" worth of data (along with some additional information) but not sure how to go about this.

The attached shows the example file. I need the following :
1. Take the data to populate the "Populate" tab
2. Using Column F (Invoice Date Created) to only bring back the "previous month data" - in this case it would be May 2014
3. The following formula is what I have currently for Column B of the "Populate" tab: =SUMPRODUCT(SUMIFS('Data'!$N:$N, 'Data'!$M:$M, "Invoice Payment Processed", 'Data'!$A:$A, A2))
4. The above formula brings back all the values - I only want the previous month.
5. I am then not sure how to calculate Column C - which is a count of the amount of invoices that make up the total

View 3 Replies View Related

Hit Tab Button To Insert New Line And Preserve Previous Lines Formulas

Feb 23, 2014

I am brand new and I don't know a ton about macros and programming in Excel.

What I'm trying to do here in this attached spreadsheet is at the end of inputting my line, I want to hit the tab (marked in red to make it clear where) button in the cell and have it automatically create another blank line but keep the formulas the same.

Basically I just want to avoid having to right click and insert line and then drag the formulas column by column down which is difficult.

See attached : TEST2_2014 Sales & Commission Spreadsheet.xlsx‎

View 5 Replies View Related

Update A Cell Value From A Previous Sheet After Copying The Sheet And Renaming It

Nov 21, 2009

I have copied a sheet, moved it to the end and renamed it with a date that is in cell "A1"

Now after that process is finished I need it to update the date in cell "A1" of the newly created sheet with the next day's date.

I am stuck however referring to the previous sheet to update the date value in "A1"

View 7 Replies View Related

Populating A Cell With A Calendar Month Based On The Previous Date In Another Cell.

Jan 9, 2010

Trying to word this right. I have one cell with a date of 01/01/2010. I have other cells that I want to be equal to this cell plus 1 or more months.

For example A1=01/01/2010

I want A2 to = 02/01/2010 based on one calendar month entered into A1. So if A1 changes 03/01/2010, A2 will = 04/01/2010.

View 3 Replies View Related

Function To Put In A New Column To Get The Abbreviated Year And Month Of A Previous Column In The Same Row

May 18, 2007

Is there a function to put in a new column to get the abbreviated year and month of a previous column in the same row???

Ex. Row A B C D
3/14/2007 5/16/2007 2007-3 2007-5

Instead of using the YEAR MONTH funcion for each row is there a universal function that I could designate to the whole column of C and D something like C=YEAR(A(row#))???

View 3 Replies View Related

Make Workbook Open- Open Correct Month Workbook

Jul 8, 2006

I have Monthly sales sheets that import my cash register data into them. I wanted to set them up to do everything without being there. So I have my task manager open excel at 9:30pm everyday and it runs the macro to import the data into the correct day of the month. Here is the workbook

open macro-

Private Sub Workbook_Open()
Dim dTime As Date
dTime = Time
If dTime >= TimeValue("9:30 PM") And _
dTime < TimeValue("9:40 PM") Then
ImportData
End If
End Sub

This is in my July spreadsheet only. So is there a way to make it know which month spreadsheet to open on the 1st of the month? So come August 1st it will automatically open the August workbook and input the data for the first day? By using the date?

View 9 Replies View Related

Count Date Cells Where Date Is Previous Month

Oct 25, 2006

I have a spreadsheet which I use to track when a work request is recieved, when we confirm the request and when we action the request. I have been trying to write some code to count the amount of requests, receipts and actions we have processed in the last month.

My first column shows who the request is from
The second shows date recieved
The third shows date we send receipt
The fourth shows the date actioned.

View 9 Replies View Related

Insert Row At Every Change In Month

Oct 2, 2007

I would like to have rows inserted before the beginning of each Month

Eg:

12/21/2006
12/21/2006
Insert Row
1/11/2007
1/11/2007
1/18/2007
1/18/2007
Insert Row
2/8/2007
Insert Row
3/1/2007
3/22/2007
Insert Row
4/5/2007
4/26/2007
4/26/2007
Insert Row
5/17/2007

View 10 Replies View Related

How To Dynamically Insert Rows With Duplicate Data Of Previous Rows

Oct 30, 2013

I have a spread sheet with values in the area of A1:H834

In column H, I have number values from 1-7.

Essentially that number value means that the values in the row are duplicate.

So, for example, if H2 has a value of 4, that means that $A$2:$G$2, really should have an additional 3 rows underneath with the EXACT same data in each cell, however, the way the sheet was created, was to remove the duplicate values and just indicate in column H, the number value of how many duplicates $A$2:$G$2 really is.

I need to unpackage this and create what it was originally. What type of formula can I use, to look at the value in H2, and then insert underneath that number of rowes with the exact same data as A2:G2 and do the same for the remainder of the table all the way down to A834:G834

View 1 Replies View Related

Macro To Insert New Rows Based On Commas In Previous Rows?

Mar 15, 2014

I'm a macro novice and have been trying to teach myself how to write the correct one for a task I need to do, but I cannot seem to get it right. Basically, I have bunch of data and for one of the variables, different values are separated by commas. What I want is to create a row copying the info below for each piece of data after the comma.

Sheet1

A
B
C
D

[Code].....

I suspect there is a fairly easy way to do this, but I cannot figure it out from searching the forums (or rather, I can't get it to work right).

View 6 Replies View Related

Check Whether Date Is A Month After Previous Date?

Dec 12, 2013

I'm sent a file every day where column A contains a month & year but in "general" format.

For example;

Column A, starting with cell A1 with the next date in A2, etc
Jan15
Feb15
Mar15
Apr15

Is there a way through a formula or macro that I can use in order to run through all the dates in this column to make sure that the next cell down is always the month after the cell above it? The dates go all the way through to 2018 in the above format.

View 3 Replies View Related

Update Sheet From Previous Sheet

Feb 9, 2009

what im hoping to do is when i press macro button"click to sort" on sheet totals

it will automatically input the totals from "TOTALS" underneath the right name and put the date in column a the trouble is the cells are dependant on the sort so if i was to press "click to sort" now it would transfer this data to sheet "PTS AND DATES"

09/02/09 in cell a2
1146 in b2
861 in c2
860 in d2
849 in e2
806 in f2

the very next time i press it , it will put data into row 3.

View 13 Replies View Related

Refer To Previous Sheet

Nov 24, 2009

I've got a workbook that increments in sheets for each new week. I have a cell showing the current week number for that sheet ( lets say cell C1) and any formulas that need to reference data from the previous sheet do in 'indirect' function which basically looks at the current week number ( lets say week 20)in cell C1 and minus's 1 to navigate to the previous week (week 19).

I was wondering if there was a way to reference the previous sheet purely by the order they're in.

So say i have 5 sheets named "1,4,5,8,9" and these represent week numbers so the sheet named '8' in cell C1 would have '8' standanding for the week number but cells that wanted to reference the previous sheet couldn't do the 'indirect' C1-1 as there is no 'week 7'.

The weeks used could vary alot so a formula to reference the directly previous sheet is needed.

ok, thought best if i show you the actual formula

=IF(ISBLANK(C12),"",IF(ISERROR(VLOOKUP(C12,INDIRECT("'"&($AG$2-1)&"'!$C:$AG"),28,FALSE)),G12,SUM(G12,VLOOKUP(C12,INDIRECT("'"&($AG$2-1)&"'!$C:$AG"),28,FALSE))))

the '$A$G2-1' part is the bit that redirects to the previous sheet based on it's name, what i think i really need is to replace this part with a 'PrevSheet' function but i'm unsure how.

View 11 Replies View Related

Reference Previous Sheet

Oct 5, 2005

I've found on this newsgroup a function to get the previous sheet
name

Function PrevSheet()
On Error GoTo EndFunction
Application.Volatile True
PrevSheet = Application.Caller.Worksheet.Previous.Name
Exit Function
EndFunction:
With Application.Caller.Parent.Parent.Worksheets
PrevSheet = .Item(.Count).Name
End With
End Function

when i put =PrevSheet() i get the previous sheets name

What i want to be able to do is use this in place of directly
referencing the sheet name in my code as follows...
=IF(G4-J4<0,G4-J4,G4-J4)+'Week 1'!H4
So i want to be able to replace Week 1 with PrevSheet but i've tried
and falied on this. eg...

=IF(G4-J4<0,G4-J4,G4-J4)+PrevSheet()!H4
Could someone show me the correct syntax for this.

View 14 Replies View Related

Goto Previous Sheet

Apr 3, 2007

I am writing a macro that goes from one sheet to another sheet to copy data but then must return to the 1st sheet to paste it.

Is there a command for returning to a previous sheet.

Note that the sheets may not necessarily be in consecutive order ie. the 2nd sht may not be immediately after the 1st sheet in the sheet tab order.

The spreadsheet will be made up of a number of sheets that can use the same macro to reference a master sheet to copy and return data.

View 6 Replies View Related

Insert And Fill Column Up To Where Data Is In Previous Column

Nov 23, 2012

I am after a macro to insert a column lets say between column A and B. Once column inserted new column B should be filled by a text say "January" but it should be only filled upto the data of column A so if column A has data upto A600 then column B should be filled from B1 to B600.

I tried recording but it fills data upto B65000+.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved