In my sheet I have a cell that has the year in 4 digits plus 5 other digits for incidents in our fire dept. (ie 2008#####) what I want is to have the year automatically change to 2009 on the first day of the new year.
I need a macro where I can highlight a column and change all of the 2 digit years to a 4 digit year (actually, some of the 2 digit years are only 1 digit, e.g. "9" instead of "09").
I have an if then statement that I can use in the column after it, but I'd rather change the actual numbers in the original column, rather than adding another column (and having to keep the original, too).
The statement I had was: =if(A1>=50,1900+A1,2000+A1)
I just copy dragged down to get the cell numbers for the rest of the column... but using A1 was just for an example, here, it's not necessarily going to be in that column. It needs to be just whichever cells I select.
It seems like it should be pretty simple, but I don't know how to word it in a macro.
I have been using the following to change the year in the Header
Code: Sub Change_Format() ' Ctrl-y will change the year per individual sheet ActiveSheet.PageSetup.RightHeader = Format(Now(), "YYYY") End Sub
Is there a way to have this done automatically? There are absout 6 sheets in the workbook that have the year in the header and right now the code is in Module 3 and I have to press ctrl+y for every sheet.
I have a sheet where column A5 to Axx is filled with date from 01. jan to 31.dec. I.E. A5= 01.01.2008 A6= 02.01.2008 A7=03.01.2008 etc etc
Based on comparing the date the sheets collecects data from other sheets. It works fine, but I want the possibility to change the year by entering i.e 2007 in cell A1 and then the sheets change Cell A5 to 01.01.2007. I know i can use replace function manually, but when i want to simulate/compare betwen years it would be very nice to just enter the year and the sheet would collect new data.
Cell B1 conatins the date 01/01/2007, and cell B2 contains the date 31/01/2007. I repeat this for every month of the year.
I want to be able to change the year of these dates in B1 and B2 from a seperate cell on another page.. so I can change the search ranges to 2008 without going into each cell and changing it manually.
I'm using this formula to count how many times the date in column C and the text "WON" appears in column I and it falls within the month & year that is in Z65.
I have a macro called pull that contains a year several times -see sample code below
I woulsd like a macro that will prompt and enable me to change the year from say 2013 to 2014 on the Macro called "Pull" . I intend to set up button to link to the macro
With Workbooks("Fruit & Veg Dept Commisions.2013.per Budget.xls") With .Worksheets("Service") Set cfind = .Cells.Find(what:=CDate(mmonth), lookat:=xlWhole) .Cells(9, cfind.Column) = x
I've been heavily updating my Budget file I've written in excel. The code I'm working with and having slight trouble with is as follows
Try this formula. Column letter & Row number are for example only. Array formulas will have curly brackets {} emcompassing the ENTIRE formula. You do not add these, you Enter the formula with Ctrl+Shift+Enter and Excel will add them (details: Array formulas). Many more Excel Formulas  Z100 =IF(TODAY()>DATE(2013,1,31),"January's Ending Balance is:",IF(TODAY()<=DATE(2013,1,31),"January's Current Balance is:"))Â
Basically, if the current date is after the last day of a given month (in this case January 31), then the cell should display "January's Ending Balance is:", if between January 1, (current year), and January 31, (current year), it should display "January's Current Balance is:". The code above does work great, but I need it to look at the current year according to the computer's date, and go by that, instead of having to change the code where it says 2013 to 2014 etc every year. This would be a hassle, as I have a tab coded for each month of the year. Id rather it be automated.
I need to calculate SUM and AVERAGE of rainfall for each and every year separately and must be displayed separately in a separate column. For your easy understanding, I have done manually and attached the excel sheet.
I am looking for Macro code preferably to get list of dates with Saturday / Sunday in a separate columns which falls Saturday and Sunday on imputing the year.
I am trying to import txt files into Excel but instead of inmporting every row, I use the following method to select only the rows I want:
Much ADO About Text Files
However, it mentions a schema needs to be created.
For example:
[File1.txt] Col1=Name Text Col2=Age Integer [File2.txt] Col1=Name Text Col2=Age Integer
This is not a problem if I know the names of all the csv files I am importing (I can create one manually) but since I don't know how many files need to be imported, how can I create a schema for it?
Would it be possible to use VBA and create the schema dynamically?
Is there a way to change a line of vba code using an input box?
The current macro downloads a file from our intranet. However the filename changes each week. It is only the last portion of the filename that changes since this part is the date it is created. e.g filename010507.xls filename090507.xls
What I want to do is for an input box to pop up, the user then enter the date and this will then replace the existing filename in the code with the new date.
I am trying to automate the status date on worksheet so that if ANY data is changed/ added/ deleted within a range (cells "B6:L34"), the status date will insert today's date in Cell "S6" but if the worksheet is open and no changes occur within that range, the date remains the same. I used this code below and it is not working.
Private Sub Worksheet_Change(ByVal Target As Range) Dim R1 As Range Dim R2 As Range Dim InRange As Boolean Set R1 = Range("S6") Set R2 = Range("B6:L34")
I am trying to create a model that has a mixture of conditional formatting and data validation formulas within it, but have run into a problem in one area. Essentially, cell E10 is a Validation which pulls a drop down list of names. One of the options in this list is "Other".
I want to create a VBA code to make sure that cell E12 will get rid of any input, turn grey (color index = 15), and potentially lock (if possible!) if the "Other" is chosen by the user in cell E10. If any other value is chosen for cell E10, Cell E12 needs to remain unlocked and white (color index=2).
I have two combo boxes: One for entering the Year, and one for the month. I can produce a message if the user leaves either box blank but I want a message to apear it the user selects a year AND month less than the current year (iYear) and current month (iMonth). I therefore need an AND statement between the two criteria but i dont know how to do it.
'....First Checks the Comboboxes arent blank then below Checks a future month/year secection is chosen
ElseIf YearBox.Value = iYear & iMonthbox < iMonth Then MsgBox ("You may not enter Data before the current Month") Else '...... Run main code here
I'm uploading a sample worksheet- on the scenario A tab, there is a pivot table that are pulling from the data range that is between B3:c13. I copied tab A and made tab B. However, on tab B, the pivot table is still pulling from the data range on scenario A even though I need it to be pulling from tab B.
I do not want to use dynamic ranges because the pivot table is being used to make a pivot chart. How do I get it so that on the scenario B tab the pivot table automatically pulls from the right tab?
I have also have a macro/VBA (I don't know what it is considered, I just copied code from somewhere online) that automatically refreshes all pivot tables (there are other pivot tables being used in the spreadsheet). If I did need to use vba/macro to accomplish what I need to do, where would I copy/paste it in the code I currently have (not sure if the button I have in sample will work properly)?
Sub Refresh() Dim PT As PivotTable Dim WS As Worksheet For Each WS In ThisWorkbook.Worksheets For Each PT In WS.PivotTables PT.RefreshTable Next PT Next WS End Sub
On tab B, I manually created another pivot table to show what I want the end result to look like. The pivot table between rows 22 and 24 and the corresponding pivot chart between columns E and M (lets call this pivot table/chart #1) is what I'm trying to manipulate. The pivot table between rows 26 and 28 and the corresponding pivot chart between columns o and V is what I want the end result to look like. I made pivot table/chart #2 by just manually setting the data source to be "ScenarioB!$B$3:$C$13.
However what I'm trying to do is get it so that pivot table #1 would automatically refer to ScenarioB!$B$3:$C$13 instead of ScenarioA!$B$3:$C$13. I created the tab "scenario B" but just duplicating the scenario a sheet. Thus, when I duplicate, the pivot table still incorrectly refers to data on the scenario A tab. I want it to pull from the scenario B tab.
The data range between $B$3:$C$13 automatically pulls from another sheet in my real spreadsheet.
I was using this code in a sheet that contained combo boxes and it worked great. When I redone the sheet a used data validation instead of CB it wold error out.
Code: Sub savee() Range("A4:J22").Select For Each Cell In Selection If Not Cell.HasFormula Then Cell.Value = UCase(Cell.Value) End If Next Cell Range("h4").Select ActiveWorkbook.Save End Sub
I'd like to create a macro that searches a column within a changing, variable range.
For example, I have a roster with a list of teams. Each team is separated by a blank row. In each team, there are a varying number of team members, and one team leader. Column I has the position code, which designates whether the person is the team leader (SL), or just a team member (RD).
What I'd like to do, is search each team for the team leader, then check another column (Col A) just within that team for another value, and if that value is present return the last name of the team leader as well as the name of the member with the value in Col A.
The problem is, I'm not sure how to search a varying range in Col I. Teams can vary in size from 3-11 members (including leader), and the number of teams varies each day. I don't have the option of changing the format or layout of the roster - it's automatically generated by some other program and given to me in a CSV list.
For example, from this sample data of two teams
Testing Program : DKSFS Scoring Center : Concord Rater Schedule Date : 07/29/2013
[Code]....
how to define that range in Col I which changes with each new team. My approach is to find a way to search a range (essentially the values between blank cells ) in Col I for the value "SL", then search that same range in Col A for the value "VM". If there's a value of VM within that range (team), then copy Cols A-E, write them to a list, and insert that person's team leader last name at the right.
how to define a dynamic range in Col I? I already have a working macro written which generates that last time, sans team leader name, just trying to figure out how to search that changing range in Col I for each team to find team leader name.
Note, not all teams will have a member flagged with that VM marker in Col A.
I have a workbook, that when opened the first time needs to prompt the user to save it. I got that working with no issues by using
Private Sub Workbook_Open() SaveOnOpen End Sub
where SaveOnOpen is a procedure in another module. What I would like to do now is re-assign the Workbook_Open sub to be set to null, so that it doesn't run any more. Is it possible to somehow assign Workbook_Open to call a null procedure, as opposed to setting up an onTime call to delete the code itself?
I have made several Shapes and assigned macros to them, all is good.
What i am curious about: is it possible to highlight or change colour of the shape on press and return to normal if another is shape is pressed? Just anything to make that particular shape stand out that it has been selected then return to normal when another shape has been selected...
[Code] ....
That is the code so far that is attached to 1x shape...
Is it possible to write VBA code that will prevent a user from changing a cell's contents, depending on the cell's font color?
More specifically, I have a column of text in range B15:B64. Some of the cells will have a black font, others will be blue. Is it possible to lock the black font cells only, leaving the blue cells unlocked for users to change?
Code: If .Range("K" & t) = "AUTO" Then .Range("K" & t) = Format(Application.VLookup(.Range("A" & t), rcore, 54, False), "h:mmA/P") With .Range("K" & t)[code]....
It is intended to change the font colour to white when the cell = "AUTO". It does, but it also changes the contents of the cell (like NA, and NR) to white when they aren't equal to AUTO.
Looking for a formula to compare current year values to previous year values. For example, if the current year has values for the month of January through March (100, 100 and 150), current year value will be 350 and the previous year value will be 975 (i.e. 300+275+400). The aim here is to make the previous year months summation equal to the present (or current) values. As new values are entered for the current year, the previous year's values will have to change to reflect the new month's value entered for the current year.
Month 2012 2013 Jan 300 100 Feb 275 100 Mar 400 150 April 650 May 454 June 800 July 500 Aug 375 Sep 525 Oct. 300 Nov 410 Dec 510
Sample file is attached : Comparison_Years.2011.xls‎
I am working on a budget for myself and want it to have running dates so the first data column will have the current month. I was able to succeed with this using the EOMONTH function followed by EDATE functions in the following cells, I then have these columns filled using a nested VLOOKUP MATCH function pair.
The problem I run into is with the months that extend into the next year, in my data table I have month by month listed started on 01/01/2014 ending 12/01/2014 but as soon as the month is no longer January the last column in my budget cannot find the information needed due to it looking for 2015. so what I would like to know is if there is a way to make the data table change the year to the following year after today is beyond that month, so for example on March 1 2014 both January and February would be changed to 2015.
I have dates in my column “A”, for example (A1 cell =22-Mar-1971), (A2 cell=30-Dec-1965). Now my requirement is in B column date and month from A column and year should take current year. Output in B column (B1 cell =22-Mar-2009), (B2 cell=30-Dec-2009)