I have months in my column header and I want Excel to Fill them in sequentially. It currently does this by default but it is filling in the long month even though it understands my short month.
Eg: I manually wrote in 'Sep' for September but it fills 'October' in the next column instead of 'Oct.'
I know Excel has both versions of months stored in it's default Custom Lists. How do I get it to switch?
You can use this formula :
=Text(A1,"mmm")
Where A1 is the cell/column/row, thus u can change it to your requirements.
After typing that formula drag it along the following rows and it will apply the formula accordingly.
Also for further refrence and/or questions u may also check this.
You can use this Formula in VBA to fill the rest of the months:
[A1] = "May"
[B1:L1].Formula = "=TEXT((A1 & "" 1"") + 50, ""mmm"")"
[B1:L1] = [B1:L1].Value2 ' optional to convert the formulas to values
Related
I'm working on data-analysis where i would like to be able to automatize color fill when looking through large amount of data where there are abundant amount of ghost logs and taking too much of my time as they are severely irrelevant.
So what i would like to do in Excel, is to be able to color fill a cell when the number changes in a column marking a different set of logs.
For instance if there are six rows of log number 456455, i would like the code to color fill the first cell when the number changes to 456456 so that it helps me identify logs faster when i know where the sets are starting. I'm kind of a newbie when it comes to Excel but this loop would help me a lot!
Thx for your time
This can be done with conditional formatting. Use a rule that compares the current cell with the cell in the row above and format if the two are different. Note that you will need to use relative references without $ signs. In the screenshot below, the conditional format is applied from row 2 to 19 and in row 2 the formula compares A2 with A1, in the next row it compares A3 with A2, and so on. If the two cells are different, the cell will change colour.
If you have some knowledge in VBA, you can implement a macro that looks at the column where you have your log number and if the value changes from one cell to another, then you highlight this cell.
I attached a template of code that works for this task.
Sub highlightChange()
Dim preVal As Integer
preVal = 0
For Each o In Range("A:A")
'Go through column
If o.Value <> preVal Then
o.Interior.Color = vbRed 'Color the selection
End If
preVal = o.Value
Next o
End Sub
There may be other solution without VBA, however, it is quite easy and practical to use a macro.
I am trying to simplify a process of counting how many of a specified criteria are in a table.
What I need is to count the number of items that meet all of the following criteria:
[BusinessArea] = "Corporate"
[Application] = "CS"
[Status] = "Resolved"
[ResolvedDate] = *if the resolved date is between DateA and DateB eon a
separate worksheet.
I can do it using VBA or Formulas but I just cannot figure out the date part. I have them figured out separately as:
=IF(AND(Sheet1!I71 >= (TODAY()-7), Sheet1!I71 <TODAY()), TRUE, FALSE)
Where i71 is the [ResolvedDate] (it is searching just this one entry without the other filters.
=COUNTIFS(Table8[Business Area], "Corporate", Table8[Application], "CS")
Where it counts the number of entries that are Corporate_CS entries.
What I currently have:
'=COUNTIFS(Table8[Reported Date],AND(Table8[Reported Date]<='Ticket Summary'!F61, Table8[Reported Date]< TODAY()),Table8[Business Area], "Corporate", Table8[Application], "CS")'
Where F61 is a previous date (beginning of range)
Of which it is returning 9 instead of 6. There are 9 entries that match the criteria, 6 matching the date range and criteria
Try this:
=COUNTIFS(Table8[BusinessArea], "Corporate", Table8[Application], "CS",Table8[Status], "Resolved", Table8[ResolvedDate], ">=" & I61, Table8[ResolvedDate], "< " & I71)
I'm assuming that I61 is the start date and I71 is the end date.
I used this as a guide for the dates: count-cells-between-dates
Multi-criteria counting is a little tough in Excel. I used to make extra columns and concatenate values. Then you can use countif without too much trouble. But it was messy. You could also use DCOUNTA by setting up your query parameters on another part of your sheet (but it doesn't like tables - only cell ranges). Again, its a little messy, but it's very flexible.
My preferred method is to use the SUMPRODUCT function. Everything can be done in one formula and it works with tables. To get your count using SUMPRODUCT:
=SUMPRODUCT((Table8[BusinessArea]="Corporate")*(Table8[Application]="CS")*(Table8[Status]="Resolved")*(Table8[ResolvedDate]>DateA)*(Table8[ResolvedDate]<DateB))
i need to write vba code wherein cell GQ4 has formula
ActiveCell.Formula = "=SUM(CO4:CQ4)"
Now there is new month added every month in excel data hence the formula will also change dynamically every month.
ie next month it will be
"=SUM(CP4:CR4)"
in short it is dragging its column selection by 1 column
Please help me write a vba code that will dynamically change the formula.
Note sure if it is possible to return a formula from a custom function, but a solution might be to write a custom function that returns the range you want, and then have the formula in GQ4 take the range as an argument.
Or you can solve it with a normal worksheet formula.
=SUM(INDIRECT(ADDRESS(4;15));INDIRECT(ADDRESS(4;16));INDIRECT(ADDRESS(4;17)))
Replace the column numbers with a base + offset that you can get by using a date function. E.g.
=SUM(INDIRECT(ADDRESS(4;14 + =MONTH(TODAY())));INDIRECT(ADDRESS(4;15 + =MONTH(TODAY())));INDIRECT(ADDRESS(4;16 + =MONTH(TODAY()))))
I have a column with many thousands of rows. The column is meant to be date and is of the format dd/mm/yyyy
But, when I try to do formulas based on the dates, something is clearly amiss.
For example, if you try to apply autofilter on the dates, some of them are grouped as a year with the expandable boxes while others appear as their own items.
For each record I tried a formula to parse it apart.=DATE(RIGHT(A2,4),MID(A2,4,2),LEFT(A2,2))
That did not help.
I also selected the column and switched it from general to date format
I really don't know how to ask the question any clearer. I can tell you that with a date of the format 1/11/2013 when I run =year(right(A1,4)) I get 1903 instead of 2013. When I run =date(right(A1,4),mid(A1,3,2),left(A1,2)) the formula returns 2/10/3192
It's very simple why your formulas doesn't work corectly. When yor're using somehting like this: RIGHT(A2,4), your value from A2 translates to 41579 for 1/11/2013 (Excel stores all dates as integers and all times as decimal fractions. You can read more here). Next formula should work well:
=DATE(RIGHT(TEXT(A2,"dd/mm/yyyy"),4),MID(TEXT(A2,"dd/mm/yyyy"),4,2),LEFT(TEXT(A2,"dd/mm/yyyy"),2))
Btw, if you'd like to get correct format for dates, you can add formula in some empty column (but before set date format for this column):
=A2*1
and drag it down. Then copy values from this temp column and paste them using "Paste special->Values" in colunm A (where should be date format as well)
Or you can use this simple macro:
Sub test()
With Range("A2:A100")
.NumberFormat = "dd/mm/yyyy"
.Value = .Value
End With
End Sub
I know excel "programming" is not very popular among fellow programmers, however I've been struggling to get this right and management is on my neck..
I have the custom validation on excel :
=AND(LEN(AV15)=10,((VALUE(LEFT(AV15,2)))<=31),NOT(ISERROR(VALUE(LEFT(AV15,2)))),MID(AV15,3,1)="/",((VALUE(MID(AV15,4,2)))<=12),NOT(ISERROR(VALUE(MID(AV15,4,2)))),MID(AV15,6,1)="/",((VALUE(RIGHT(AV15,4)))<=2100),NOT(ISERROR(VALUE(RIGHT(AV15,4)))))
The validation above is supposed to accept any valid date in the format:
dd/mm/yyyy
It seems to be working partially, but somehow it wont accept a day lower than "12", example:
14/12/2010 -->accepted
13/10/2010 -->accepted
25/10/2010 -->accepted
12/10/2010 -->gives error
At first glance one would thing that the ((VALUE(MID(AV15,4,2)))<=12) is causing this behavior, but I changed it to 31 and I still get the error, I need the validation to admit inputs in :
nn/nn/nnnn
where "n" is a number, i don't care if they input 99/99/9999 I can check that later on vba code, but the input has to specifically have the 10 characters.
any help would be highly appreciated
I put your formula in and when you put a ' before the date it works just fine. What is going on is that when you put any value below 13 as the day it evaluates the date like a date, which is stored as a number in Excel. When you have above 13 it evaluates as a string. So what you need to do is format the cell to Text format. Then it should work just fine.
To see if the following works, put the date value in A1
A1 -> '14/12/2010
Put the following formulas as mentioned below
B1 -> =MID(A1,3,1) = "/"
C1 -> =MID(A1,6,1) = "/"
D1 -> =IFERROR(AND(VALUE(MID(A1,4,2)) >= 1, VALUE(MID(A1,4,2)) <= 12), FALSE)
E1 -> =AND(VALUE(RIGHT(A1,4))>=2000,AND(VALUE(RIGHT(A1,4))<=2100))
F1 -> =AND(B1,C1,D1, E1)
The formulas above are splitted and you will have to combine them (as it is done in cell F1).
Hope that helps.
EDIT: The combined formula for validation will be (note that I have used A1 as the cell)
=AND(MID(A1,3,1) = "/", MID(A1,6,1) = "/", IFERROR(AND(VALUE(MID(A1,4,2)) >= 1, VALUE(MID(A1,4,2)) <= 12), FALSE), AND(VALUE(RIGHT(A1,4))>=2000,AND(VALUE(RIGHT(A1,4))<=2100)))
Can you not simply choose the correct format in the cell?
Right click in the cell and select 'Format Cell'
Select 'Custom' from the left side navigation
In the 'Type:' box enter this: dd/mm/yyyy
Excel appears to be recognising values such as 10/12/2010 as dates and storing them internally in a different format, such as the number of days since Jan 1 1900 or suchlike. It happens that when you use LEFT, MID and RIGHT on these date values, Excel doesn't do the conversion back from its internal format. In particular, I put 10/12/2010 in cell A1 and =LEFT(A1,10) in cell B1. Cell B1 then showed me the value 40522. (I'm in the UK and using Excel 2010 Starter. You may get different values in other locales or with other versions of Excel.)
Try replacing all occurrences of AV15 in your formula with TEXT(AV15, "DD/MM/YYYY"). Alternatively, put =TEXT(AV15, "DD/MM/YYYY") in another cell and use this other cell in your formula in place of AV15.
If you aren't wary of VBA, then what about a simple UDF?
Public Function DateFormat(rng As Range)
Dim regEx As Object
Set regEx = CreateObject("VBScript.RegExp")
regEx.Pattern = "\d\d/\d\d/\d\d\d\d"
test = regEx.Execute(rng.Value).Count > 0
End Function
This should return true if the value of a cell matches nn/nn/nnnn where n is any number.
Then you could simply say =DateFormat(AV15)