Dynamic Date In A Macro
Dec 12, 2007
I have the following code in my macro which open a file where the suffix changes everyday with the date of the day:
Dim FN As String
FN = Format(Now(), "YYYYMMDD") & ".xls"
Workbooks.Open Filename:="S:BSGWFDIMyfile " & FN
My question: What code should i write to open a file where the date= D-1 where D= business day (from monday to friday only) ? Basically i want to open the file with yesterday date (Myfil20071211.xls)?
View 9 Replies
ADVERTISEMENT
Feb 23, 2014
I have a requirement to download a lot of historical data files from the archieve of an website. The url goes something like this: [URL]....
This downloads file for 21022014 ie. 21-Feb-2014. I need to be able to have a facility to have a selection criteria on my user form (in excel) where I specify a date range and the macro automatically downloads all the valid excel files available within that date range (files for Saturday, Sunday and some holiday dates will not be available in the website archive database) one after the other (like at single clcik of button) into a specific location (predefined viz.. c:/Users/EOD files/) on my laptop. Best would be if I am able to select the save location run time by using a 'Browse' like feature where I go and choose my local laptop folder...same type when we try uploading a file from our laptop to the web..
View 1 Replies
View Related
Jan 30, 2013
I have data in a spreadsheet similar to the below.
[Code] ....
What I need to do is created a named dynamic range based on the current month which will contain all rows/columns within that range. Ideally I need it to create the range for the current month so I can then use this as the data source for a pivot table.
I believe it is something to do with index and match functions?
View 1 Replies
View Related
Aug 24, 2013
If I want date to be current and time constant how to do it for ex:
in A1 want display of 8/23/13 8:00 next day when I open excel A1 should display 8/24/13 8:00
so my date is dynamic but time is static.
View 6 Replies
View Related
Dec 2, 2008
I need to filter data which is 3 months from todays date or older. I'm going to use it in a macro which downloads the information from our accounts system.
I have set up the filter and it works fine when I manually put the Date in, but when I use the date 'formula' for todays date -3 months and reference the cell its in, it does not work. Here's what I have so far :
The filter from the macro :
Range("A:I").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("J1:J2"), Unique:=False
The way I work out the date 3 months from now (in cell K2) :
=DATE(YEAR(TODAY()),MONTH(TODAY())-3,DAY(TODAY()))
Cell J1 has the relevent Column Header
Cell J2 has the following formula :
=" < K2 " (there are no spaces I had to put them in so the post appeared correctly!)
View 9 Replies
View Related
Oct 26, 2012
I am creating a spreadsheet that will display the subject mentioned. I need a chart that displays project deliverables as labels along a year long date range. I want to be able to change the date range to any period of time by entering a start date and an end date and having the chart automatically update to that date range and display the project deliverables due during that range. I have used the following links and have been able to accomplish each of them individually, but have not been able to combine the labels of the project timeline link with the dynamic date range described in the second link.
[URL] .......
[URL] ......
How to achieve the spreadsheet I described using the two ideas presented in the link?
View 1 Replies
View Related
Feb 4, 2014
I have a long (~42,000) list of dates and times (some including zeros). I would like to name these ranges and use a formula to find the last entry in each column. I know the lists will never go over 45,000.
The data is in this format:
1/31/14
23:58:00
1/30/14
[Code]....
The data will not always be consecutive, so I imagine the criteria would be something like (if there were such a thing) "ISDATE" or something of the sort.
How would I write a formula to dynamically calculate the row number of the last date or time in the column? (In this case, it would be 6.)
View 9 Replies
View Related
Oct 26, 2008
I have a list of dates going through several years of data - month ends and starts don't always coincide with calendar months. I need to figure out a way to get the oldest date of the previous month, for example. Tried vlookup but could figure out how to do it for one year only, hence not as applicable with several years of data.
View 9 Replies
View Related
May 23, 2007
Some of you may have seen my 2-dimensional Date Range Criteria thread . By request, that thread has been closed and I am opening a new one on a related, but infinitely more complex note.
The solution to the previous thread worked, but not well with my project. I'll go a little more in depth into how my project works, and try not to be too detailed and irritating.
I am trying to create a homebrew Learning Management System for some of the Training courses that my department offers. I've posted here a few times on the same project, and the advice from all previous posts has been excellent.
What I have so far allows users to input all of the relevant information about a participant, and then keep track of the dates when they took a particular course. They input this information with a Userform. This data goes into a Participant Master List, which is where the majority of the functions take place. There is a Workings sheet set to xlVeryHidden, which houses some other information, including results for searches, and finally there is the Report Template--the source of my original question.
The original question was how to make a formula that would track how many people from each department and site have attended training within a date range. That question was answered in the 2-dimensional Date Range Criteria of the report.
What makes it potentially more complicated is that a user might want to generate two or three reports at the same time to compare side-by-side. I'm pretty sure I can make something that will do this, and allow it, but the way it's looking could be really complicated--extreme headache, and a lot of VBA coding.
View 9 Replies
View Related
Mar 9, 2008
I want to define a dynamic named range based on the last date in a range (AE4 down). Unfortunately there are gaps in this range where no date is in a cell.
View 5 Replies
View Related
Jan 2, 2014
I am trying to build a workbook to track patient treatments. My overview sheet needs to list the last treatment received per patient which is listed in column a of each patient's individual sheet dynamically so I can review the history of treatments as well. I have tried to create a dynamic list, but it is not functioning correctly. I was using : =OFFSET(txdate,1,0,COUNTA('patient, name'!$A:$A),1) , where column A ( the named range "txdate") lists the treatment dates in succession and should be updated automatically when a new treatment is done.
View 10 Replies
View Related
Nov 17, 2011
I am trying wihout suceess to create a range to copy in a macro each time the macro loops. This is thus a dynamic range. My failed attempt is listed below. How is this done?
ColumnAdjust=2
For I = 1 To 282
Range ("B5").Select
Range(ActiveCellOffset(0,ColumnAdjust),ActiveCellOffset (0,ColumnAdjust+1))
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
.
.
.
ColumnAdjust= ColumnAdjust=2
Next I
View 4 Replies
View Related
Jun 21, 2006
By adapting a worksheet macro obtained previously via Ozgrid, I built a workbook that dynamically produces a database, in a worksheet titled “NumLtrWBS DB”, based on all possible combinations of what is listed in column A of three 3 worksheets titled: “ Num”, “Ltr” and “WBS, respectively. The macro, named “NumLtrWBS", works wonderfully, until I add a row at the top of each list to contain a column header. The unchanged macro includes the column headers in the “produced” database. When I change the macro by altering the variable definitions to begin at A2 rather than A1, it still includes the column headers in the “produced” database. How should I change the macro so it doesn’t “produce” the column headers in the database worksheet?
View 4 Replies
View Related
Jul 1, 2006
I've recorded a macro where I have selected two adjoining cells in Row-9. I double-clicked at the cells to fill-down the formulas to the end of the range. However, the macro recorded: Selection.AutoFill Destination:=Range("H9:I152")
Of course, I will be adding and deleting rows from this worksheet. The next time I run the macro my range may only be to row 80 or it may be up to 200. How can I make the macro dynamic, so the AutoFill goes from H9 to "the end of the range"?
View 2 Replies
View Related
May 28, 2007
I am attempting to create a dynamic range within a macro.
Each week, a list of performance factors is recorded for employees. The macro is about to do an Advanced Filter to create reports based on user-provided criteria. Since there is new data every week, the range used for the Advanced Filter is dynamic. The code for the Advanced Filter refers to a range entitled “Database.” My problem is in defining “Database.”
It is currently 534 rows and 8 columns, starting at A1.
The relevant portion of the macro currently reads:
Sub Check1()
ActiveWorkbook.Names.Add Name:="Database", RefersToR1C1:= _
"=OFFSET('Loan Officer History'!$A$1,0,0, COUNTA('Loan Officer History'!$A:$A),8)"
Range(Database).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
"J1:Q2"), CopyToRange:=Range("J5:Q5"), Unique:=False
End Sub
When running the macro, the debugger stops at the line which starts "ActiveWorkbook.Names" and tells me “Run-time error ‘1004’. The formula you typed contains an error.”
View 3 Replies
View Related
Jun 23, 2012
I've got the following code:
VB:
Application.DisplayAlerts = False
Worksheets("WildCard").Delete
Application.DisplayAlerts = True
I'd like the "WildCard" to pull from a value in a cell whereby I can run a button macro that, when pushed, deletes the tab/worksheet named "WildCard". For instance, if I wanted to delete "Sheet3" I would type "Sheet3" into, say, cell C3 and then press the button to run the macro and "Sheet3" would be deleted. How to I refer the macro to cell C3? I currently have a macro that inserts/names a sheet based upon a cell reference and macro button. I'd like one that can delete in the same way.
View 7 Replies
View Related
Jun 6, 2013
I have a Ranking tab that has the persons name, weeks, months that subtotal into 2 columns, MTD and YTD. I have set up with 2 Macros to sort based on two columns based on their selection of MTD or YTD.
What I did not take into consideration is if a person was added at the bottom of the list.
Is there a way to modify this to include rows that may be added?
VB:
[SIZE=4]CODE HERE[/SIZE]
VB:
[B]Macro1
[/B]Sub SortYTD()
[Code].....
View 8 Replies
View Related
Nov 21, 2013
i currently have a workbbok that i have a very simple worksheet event macro that will filter a seperate sheets contents to the corresponding entry number. is there any way to make a dynamic event macro that will filter my second sheet depending on what cell is selceted on the first.
for example record 1 on sheet 1. if cell L1 is selected it will filter sheet 2 to to record 1, record 2 on sheet 1, if cell L2 is selected it will filter sheet 2 record 2 and so on. this list of records will continue to grow and i cant think of any way other than what i currently have, which is to make each filter macro for every cell.
is ther a better way example of CODE HERE
VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$L$5" Then
Call Filter1
[Code]....
View 2 Replies
View Related
Jun 23, 2014
I am trying to make a dynamic pivot table using VBA. Unfortunately, Im not very good.I have a set of data with variable number of rows and variable number of columns and I need to make a pivot table. Need to select this data from sheet - Master, where the first data entry starts in cell A1. of the data in the sheet, i only need the name and age title In the pivot table fields -
ROWS needs to contain - name
COLUMN needs to contain - Age
Values need to contain - count of Age
After this is done, since the data will be dynamic, the pivot table will also be dynamic. i need to copy the pivot table data and paste it in another sheet so that I can do some filtering. The filtering part I think i can do my self.
View 3 Replies
View Related
Feb 10, 2014
I'm currently using this macro:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Rng
Dim MyCell
Set Rng = Range("A1:AA7672")
For Each MyCell In Rng
[Code] ....
The problem is that it is not dynamic and it's super slow. The larger my range is the slower it operates and right now it's almost unusable.
The workbook I am using gets touched by 10 different people and I want to prevent tampering. I want for the workbook to be, when protected, have all the blank cells editable and once a value is inserted, it cannot be edited again and not work so unbelievably slow.
View 5 Replies
View Related
Sep 6, 2007
I recorded this macro based on a column with a drop down window in which data has been filtered .....
View 12 Replies
View Related
Feb 20, 2009
I need a bit of assistance in identifying the dynamic range so that my macro below will work:
View 3 Replies
View Related
Oct 31, 2011
having trouble editing the code to allow for dynamic ranges. I have tried to research online, but am having a hard time with it. I think I would understand better if I could see a practical example.
Here is the sample macro I recorded in Excel that I am working with:
Sub Macro1()
'
' Macro1 Macro
'
'
Cells.Select
ActiveSheet.Range("$A$1:$C$87").RemoveDuplicates Columns:=Array(1, 2, 3), _
Header:=xlNo
End Sub
How can I edit this to allow for dynamic rows and columns?
View 2 Replies
View Related
Nov 30, 2011
I run a macro on a spreadheet in which the rows increase daily. In the macro I simply recorded an end.down to select a column of data which ends up being fixed row numbers in the code so the next time I run the macro it only selects the range I selected last time.
View 1 Replies
View Related
Jul 24, 2014
I am building a dashboard and would like to be able to have shapes I have created be clickable with a dynamic link to a document on our network. Something along the hyperlink() function.
In a cell, the function looks like this: =HYPERLINK(Worksheet!I34,Worksheet!F34).
The data in I34 changes, depending on the input from a drop down using a vlookup command. Is it possible to create a macro and assign it to a shape to make the shape a clickable link?
View 1 Replies
View Related
May 6, 2004
I am still having some difficulty in getting a macro to select a print range on a text file imported into excel. All the data pulls into column A which is OK. I'm trying to get my macro to highlight & select the print range by going Home, End Down, Tab right Tab right and then select whatever that highlighted range is. This range will change from file to file.
My macro reads as follows:
Sub PrintToView()
'
' PrintToView Macro
' Macro recorded 5/5/2004 by
'
'
Range("A1").Select
[code]....
View 5 Replies
View Related
May 11, 2007
I regularly get a sheet that contains about 20 columns. I need to delete about 14 of them, and re-order the columns to a fixed order.
The columns always have the same headers, but are ofter in different positions (so I cannot hardcode the column location).
I have tried using the following, but fail on trying to use the result of the find in the selection afterwards.
I also do not know how to loop this through a list of column names (as I said, the input always has the same column names, and I always have to delete the same columns, and sort the remaining).
Sub Sort_My_Columns()
Cells.Find(What:="name1", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
myRow = ActiveCell.Row
MyCol = ActiveCell.Column
Columns("myRow:myRow").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select
End Sub
View 9 Replies
View Related
Sep 1, 2007
I have the following code as part of my macro. What I was wondering is a) Can anyone think of a way to shorten this? and b) I currently have this exact code copied 8 times, I did a find and replace to change 'if year = 2003 then' to the year 2010. What I would like is to have 1 code that will automatically change depending on the year the user inputs in a cell. (I should mention that 'Year' is a cell on my input sheet where the user types in the year they are currently working on and the macro automatically runs)
'2003
Sheets("Cash Crops").Select
If Year = 2003 Then
' This copies the cash crop BPU's.
ActiveSheet.Unprotect
Workbooks.Open Filename:="F:xdataCAISCAIS spreadsheetsBPU's.xls"
Application.Goto reference:="Cash03"
Selection.Copy
Windows(Filename).Activate
ActiveWindow.SmallScroll Down:=21
Application.Goto reference:="CashCrops"
ActiveSheet.Paste
ActiveWindow.SmallScroll Down:=-30
Range("A2").Select
Application.CutCopyMode = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True..............
View 9 Replies
View Related
Oct 13, 2008
I am looking to run a marco for a selection range, and the selection range could vary in size.
Using the Macro recorded (whilst turning on the relative reference) the Macro runs for a defined number of cells. I would like to run certain Macro, for different ranges of cells.
View 9 Replies
View Related
Jan 28, 2010
I am looking for a macro that will allow me to create a dynamic range based on the settings I give it. I would like the dynamic range to be called tracking_number and it to have a reference to =Offset(MainReport!$A$2,0,0,COUNTA(MainReport!$A:$A),1)
If this is possible I would really appreciate it. The reason I need this is because I have 2 workbooks. They are the one with the MainReport in it and then the Master workbook. Every day the workbook containing the MainReport is overwritten with more data, so I can not store a dynamic range and reference it each day.
View 9 Replies
View Related