Lets say we have a table like this:
A
B
1
Aaron
20
2
Bob
30
What is the difference between =""&A1&" has "&B1&" cakes" and = A1 & " has " & B1 & " cakes"?
Why do we use "&cell_reference&" anyways?
Lets say I have the following data:
A B C
1 =B1
2 =C2
3 =C3
I want to write a macro than can add text around the values in column A without losing the reference.
For example
A B C
1 [Hello].[1] 1
2 [Hello].[20] 20
3 [Hello].[10] 10
As an example for A1 I use:
.cells(1,1) = "[Hello].[" & .cell(1,2) & "]"
This give me the wanted value but in the end I lose the cell reference in A1.
I rather want this:
A B C
1 [Hello].[B1] 1
2 [Hello].[C2] 20
3 [Hello].[C3] 10
Of course with the actual value of the reference and not just the addresses.
With .cells(1,1)
.value = "=" & .cell(1,2).address
.format= ""[Hello].[" 0 "]""
End With
this should do. more info on this excel exotic syntax on that random website https://exceljet.net/custom-number-formats
best of luck, but consider using another language than vba
I have a tab that has 2 cells which list a room number and start time for a class. In this same tab I am performing a VLOOKUP formula.
=VLOOKUP(A12&B3,'Fall 2018 export - TEST'!AF2:AF4,1)
Here A12 is a class room name, and B3 contains the start time.
The array ('Fall 2018 export - TEST'!AF2:AF4,1) for the VLOOKUP comes from a different tab and contains multiple text. Each cell in the array looks like this but with different numbers and start times.
B8007-1, WJW 326,Class Length: 1.30 hrs. Start Time: 9:00 AM
Also, the cell above is a formula:
=IF(AE2<>0,CONCATENATE($C2,"-",$E2,", ",$AE2,",","Class Length: ",TEXT($W2,"h.mm")&" hrs.", " Start Time: ", TEXT($S2,"h:mm AM/PM")),0)
The issue I'm having is, every time I try the VLOOKUP formula, it gives me the wrong data.
For example: using this formula
=VLOOKUP(A12&B3,'Fall 2018 export - TEST'!AF2:AF4,1)
[with A12 & B3 values as 'WJW 100' and '9:00 AM"]
gives me this
"B8007-3, WJW 100, Class Length: 1.30 hrs. Start Time: 12:30 PM"
In other words -- it doesn't give me the cell with the correct start time.
Any help would be appreciated.
Use:
=VLOOKUP("*" & A12 & "*" & TEXT(B3,"h:mm AM/PM") & "*",'Fall 2018 export - TEST'!AF2:AF4,1,False)
i need to find the last record of each day in excel if there are multiple entries
*******intention is to get EOD balance ROW OF EACH DATE********
like i have data in excel something like this
date CR_DR amount EOD balance
----------------------
7/9/2017 19:09 CR 10 10
7/10/2017 18:37 CR 25 35
7/10/2017 21:06 DR 10 25
7/11/2017 19:21 CR 15 40
7/15/2017 14:17 DR 20 20
7/17/2017 17:12 CR 100 120
7/18/2017 7:44 DR 30 90
7/18/2017 14:08 DR 50 40
7/18/2017 16:52 CR 120 160
for which i need to get data like (get the last row of each day)
7/9/2017 19:09 CR 10 10
7/10/2017 21:06 DR 10 25
7/11/2017 19:21 CR 15 40
7/15/2017 14:17 DR 20 20
7/17/2017 17:12 CR 100 120
7/18/2017 16:52 CR 120 160
Solution 1
Enter the following formula in Cell F2
=IFERROR(MAX(IF(INT($A$2:$A$10)=INT(INDEX($A$2:$A$10, MATCH(0, FREQUENCY(IF(EXACT(INT($A$2:$A$10), TRANSPOSE(INT($F$1:F1))), MATCH(ROW($A$2:$A$10), ROW($A$2:$A$10)), ""), MATCH(ROW($A$2:$A$10), ROW($A$2:$A$10))), 0))),$A$2:$A$10,0)),"")
This is an array formula so commit it by pressing Ctrl+Shift+Enter. Drag/Copy down as required.
Then in Cell G2 enter
=VLOOKUP($F2,$A$2:$D$10,COLUMN(C1)-COLUMN($A$1),FALSE)
Drag this formula across (to right) till Cell I2 and down as required.
See image for reference.
Solution 2
Instead of using an ugly looking long formula, here we'll use a helper column.
In Cell F2 enter the following formula
=MAX(IF(INT($A$2:$A$10)=INT(A2),$A$2:$A$10,0))
This is an array formula so commit it by pressing Ctrl+Shift+Enter. Drag/Copy down as required.
Then in Cell G2 enter
=IFERROR(INDEX($F$2:$F$10,MATCH(0,INDEX(COUNTIF($G$1:G1,$F$2:$F$10),0,0),0)),"")
Drag/Copy down as required.
Finally, in Cell H2 enter
=VLOOKUP($G2,$A$2:$D$10,COLUMN(C1)-COLUMN($A$1),FALSE)
Drag this formula across (to right) till Cell J2 and down as required.
See image for reference.
EDIT : As per comment.
Instead of
=VLOOKUP($G2,$A$2:$D$10,COLUMN(C1)-COLUMN($A$1),FALSE)
use below formula in Cell H2
=INDEX(B$2:B$10,MAX(IF($A$2:$A$10=$G2,ROW($A$2:$A$10)-ROW(INDEX($A$2:$A$10,1,1))+1)))
This is an array formula so commit it by pressing Ctrl+Shift+Enter. Drag this formula across (to right) till Cell J2 and down as required. Drag/Copy down as required.
Screen-Shot :
Ok, this is crude and I'm sure there are "proper" ways to do this, but it works for what you want to do. I used columns A thru D for the data. In column F I used the formula =Left(A3,5) and copied it down. You will have to modify according to your situation. Hope this helps or gets you headed in right direction. Good Luck
Sub FindLast()
'FIND LAST LISTED DATE AND COPY
Dim myCount, myCount2, myRange, myRow, x, y, r
r = 3
myCount = Sheets("Sheet1").UsedRange.Rows.Count - 2
MsgBox "Rows used are " & myCount
For x = 3 To myCount Step 1
y = Range("F" & x).Value
MsgBox "Value of x is " & x
MsgBox "Value of y is " & y
myCount2 = WorksheetFunction.CountIf(Range("F3:F" & myCount + 2), y)
MsgBox "myCount2 value is " & myCount2
Max_date = Application.WorksheetFunction.Max(Range("A" & x & ":" & "A" & x + myCount2 - 1))
myRow = Range("A" & x + myCount2 - 1).Row
MsgBox "myRow number is: " & myRow
MsgBox CDate(Max_date)
Sheets("Sheet1").Range("I" & r).Value = Max_date
Sheets("Sheet1").Range("J" & r).Value = Range("B" & myRow).Value
Sheets("Sheet1").Range("K" & r).Value = Range("C" & myRow).Value
Sheets("Sheet1").Range("L" & r).Value = Range("D" & myRow).Value
r = r + 1
If myCount2 <> 1 Then
x = x + (myCount2 - 1)
Else
x = x
End If
Next x
End Sub
You will notice there are a lot of message boxes. I used these to test the parameters and make sure they were coming out like I wanted. When you are comfortable with how it's working, just comment them out.
Also, the output is set to I3 thru L8 for the example you posted. Please make sure to edit these if your real sheet has any data in these areas. My suggestion is test first to get familiar with what's happening. I did't put any "failsafes" or "exits" in, as I ran out of time. There are plenty of examples on this site to help with that.
Regards
It requires entering the dates in column A (I didn't feel motivated enough to figure out how to pull the unique ones out), but if you are feeling spunky, you could use some array formulas. :-)
Column A Column B C D E
7/9/2017 7/9/2017 19:09 CR 10 10
7/10/2017 7/10/2017 21:06 DR 10 25
7/11/2017 7/11/2017 19:21 CR 15 40
7/15/2017 7/15/2017 14:17 DR 20 20
7/17/2017 7/17/2017 17:12 CR 100 120
7/18/2017 7/18/2017 16:52 CR 120 160
Enter dates in column A. Then in column B enter:
=IFERROR(INDEX(Date,SMALL(IF(ROUNDDOWN(Date,0)=$A1,ROW(Date)-1),COUNTIFS(Date,">="&$A1,Date,"<"&$A1+1))),"")
closing out of the cell with CTRL-SHIFT-ENTER so that the formula in the formula bar looks like
{=IFERROR(INDEX(Date,SMALL(IF(ROUNDDOWN(Date,0)=$A1,ROW(Date)-1),COUNTIFS(Date,">="&$A1,Date,"<"&$A1+1))),"")}
Note: it does not work to enter the curly braces yourself. ;-) You must close out of the cell with CTRL-SHIFT-ENTER!
The Date in the formula is a named range - I don't like typing $A$2:$A$10 all the time. If you don't want to do named ranges, replace Date with $A$2:$A$10 or your applicable range.
Column C:
=IFERROR(INDEX(CR_DR,SMALL(IF(ROUNDDOWN(Date,0)=$A1,ROW(Date)-1),COUNTIFS(Date,">="&$A1,Date,"<"&$A1+1))),"")
Same thing - close out of cell with CTRL-SHIFT-ENTER. Named range again for CR_DR, same rules as for Date above. Copy/paste the for the other columns, changing the range that INDEX is searching as appropriate for the column you want.
Explanation: ROUNDDOWN removes the time from the date in your source data so that it can match it to the date in column A. If the date matches, its row (-1 because the row number of A2 is 2, but it is the first item in $A$2:$a$10) is put into an array for the SMALL function. This chooses the nth smallest item from the array, defined by the COUNTIFS function, which counts how many dates fall between the date in column A and the day after the date in column A (thus actually giving you the largest item). INDEX then uses the range and looks up the row number that SMALL delivered to it. If it errors out, the cell is blank.
If you don't want to hand-enter specific dates, auto-fill for all dates and it will simply be blank on dates with nothing:
7/9/2017 7/9/2017 19:09 CR 10 10
7/10/2017 7/10/2017 21:06 DR 10 25
7/11/2017 7/11/2017 19:21 CR 15 40
7/12/2017
7/13/2017
7/14/2017
7/15/2017 7/15/2017 14:17 DR 20 20
7/16/2017
7/17/2017 7/17/2017 17:12 CR 100 120
7/18/2017 7/18/2017 16:52 CR 120 160
I have the following table:
Roll No Eng Hin Mar Math
1 10 10 10
2 10 10
3 10 10
4 10 10
5 10 10
6 10 10 10
7 10 10 10
8 10 10 10
I need to find out only blank cells and highlight only those students who are left blank. For example, Roll no 1 is blank at Hin column and Roll no 2 is blank at Eng and Math:
Roll No Pending Sub
1 Hin
2 Eng & Math
Can anyone tell me how to get that result?
I have changed the layout of the data in your OP to try to match it to your example and am interpreting "highlight" as more "draw attention to" than any particular formatting.
Assuming Roll No is in A1, please try in say G2 and copied down to suit:
=LEFT(IF(ISBLANK(B2),B$1&" & ","")&IF(ISBLANK(C2),C$1&" & ","")&IF(ISBLANK(D2),D$1&" & ","")&IF(ISBLANK(E2),E$1&" & ",""),LEN(IF(ISBLANK(B2),B$1&" & ","")&IF(ISBLANK(C2),C$1&" & ","")&IF(ISBLANK(D2),D$1&" & ","")&IF(ISBLANK(E2),E$1&" & ",""))-3)