VBA - Sum multiple rows where adjacent column value matches another cell - vba

Basically, I have two worksheets - one lists all jobs completed in a day and in the 'Sales' column I have:
{=SUM(INDEX(equip!K:K,MATCH('Page 1'!F2,equip!A:A,0)))}
in each cell. The other sheet (equip) has a list of all the equipment used at each job. I'm trying to SUM the rows where the customer name is found on both sheets. Customer names are in column A of the equip sheet.
Any help would be awesome! I'm stumped.. It's probably a small error somewhere I hope.

A standard (non-array) native worksheet formula based upon the SUMIF function should do well here.
=SUMIF(equip!A:A, 'Page 1'!F2, equip!K:K)
If you actually need that in VBA then the code line would be something like,
With ActiveSheet
.Range("A1").Formula = "=SUMIF(equip!A:A, 'Page 1'!F2, equip!K:K)"
End With

Related

Find number of rows in an already filtered Column A in Excel

I have got an Excel spreadsheet. This spreadsheet has just one tab in it. The Tab name is dynamic in nature and changes every week also the number of rows.
I have column A filtered already with a VBA macro. A1 has the header.
Now, I wanna find how many rows are there in this already filtered column A.
I am looking for any VBA function.
I have tried using Subtotal function.
=Subtotal(103,A2:A1345)
But I don't know the end range. As of now the end range is A1345. It will change every time in future if the new rows are added.
I tried multiple things but those did not work. I am quite new to VBA.
If A1 will never be blank, you could use (in a column other than A)
=Subtotal(103,A:A)-1.
Or, if there will be data below your table not to be counted, then format your table as a Table and use structured references (and this formula could go into column A)
=SUBTOTAL(103,Table1[column_header])
You can put the formula in column A if you use another column's last populated cell as the demarcation point.
If column B contains numbers then,
=subtotal(103, a2:index(a:a, match(1e99, b:b)))
If column B contains text then,
=subtotal(103, a2:index(a:a, match("zzz", b:b)))

Deleting all columns between the first one and the last four on a sheet

I have a worksheet here with multiple columns full of data, ranging from cell AA to CT currently. The first column contains rows with headings and is frozen. Data is added to the end column of this range weekly. & Then all columns between the first and the last four are deleted (to show a month's worth of data but keep the headings intact).
I'm very new to VBA and I've been trying to write some code to automate this, so far I've managed to select the 5th column in from the end. But I can't get it to select the columns in between the 4th column from the end and Cell AA:
Sub DeleteColumns()
Dim i
i = Range("KFIData").End(xlToRight).Offset(0,-4).EntireColumn.Select
Columns("AA:ColumnFive").Delete
End Sub
Am I going about this completely the wrong way?
Many thanks
Well if you managed to catch column 5 from the end, use this statement:
Range(Columns("AA"), Columns(ColumnFiveFromEnd)).Delete
ColumnFiveFromEnd can be a number as well as a text identifier.

EXCEL - retrieve value of specific cell in column based off of date

My question is as follows:
I have an excel workbook with two worksheets. The first worksheet has my bills listed in rows, and paydates in columns. The second worksheet has a weekly cashflow plan with spots corresponding to various bills in the first.
I would like the cash flow worksheet to update the cell to the dollar value of the bill if its due. I have attached a link to my box with the excel file. Screen shots are below as well. In the screenshot examples, for instance, i would like the Electricity Cell in Cash flow sheet to Show $238 since the Electricity in the Bills sheet for the current week has an X in that location.
Excel Workbook
Any help that can be provided would be greatly appreciated.
If I understand what you want to accomplish correctly, your dates on the first worksheet (E3, F3, etc) need to be changed to Thursday dates - they are Wed dates right now.Also, you need the descriptions in column B of the first sheet to exactly match the descriptions in column A of the second sheet. This is why accountants like to use account numbers instead of account descriptions when possible.
If you change those here are your formulas:
Second sheet cell A2 - =IF(WEEKDAY(A3)<=5,A3+5-WEEKDAY(A3),A3-WEEKDAY(A3)+7+5). This checks the day of week of the current date then adds days as needed. It seems like there might be an easier way to get this.
Second sheet cells B6, B7, B8, B10 ,etc = =IF(HLOOKUP(A10,$F$4:$J$8,MATCH(A12,$D$5:$D$8,0)+1,FALSE)="x",VLOOKUP(A12,$D$5:$E$8,2,FALSE),""), The hlookup determines if there is an "x" in the current week and the vlookup pulls the amount from the correct line.

vlookup if name is matched display employee id

Ive never used vlookups i have a spreedsheet not sure if this is the right function. I have two sheets
Sheet 1
first name last name username
Sheet 2
first name last name employee id business unit
I need in column D on sheet 1 to have employee id ive below. Pay no attention to column letters and sheets because i moved to another sheet to try getting this right.
=MATCH(B11,Sheet1!C:C,0)
Any help is much appreciated.
So you realize you have to match both first and last names? There are several ways to accomplish this depending on how many employees you have in sheet 2: a) small list could a two-column search using array formula; b) large list just create another column in both sheets joining last & first names and do a MATCH or VLOOKUP on them.
Since your needs are simple and to illustrate option (b):
Insert a column in both Sheet1 and Sheet2 after the "last name"; you should now have an empty column C in both sheets.
Assuming you have column headers in row one, and thus data starts in row two, set cell C2 in both sheets with function =B2&","&A2, then fill-down that formula on both sheets in all rows.
Set Sheet1 cell E2 to formula =VLOOKUP(Sheet1!C2, Sheet2!$C:$D, 2, False), and fill-down that formula in all rows.
Voila, employee IDs on Sheet1. I do have to say this is so Excel 101. There are all sorts of examples and tutorials on this easily found using even the most trivial Google searches.

match column from one worksheet to another, and put a 1 under the matched column

I have 2 worksheet. In worksheet it listed in separate columns skills a person has
I now want to transfer it into another format.where I have listed all available skills, whenever there's a matched skills from worksheet1 to worksheet2, there should be a 1 output to corresponding worksheet2 columns.
Can anyone help me do that?
Assuming that both of your worksheets start from A1...
Sheet2 = D2 formula would be
=COUNTIFS(Sheet1!$A$1:$A$100,Sheet2!$A2,Sheet1!$E$1:$E$100,sheet2!D$1,Sheet1!$F$1:$F$100,sheet2!D$1,Sheet1!$G$1:$G$100,sheet2!D$1,Sheet1!$H$1:$H$100,sheet2!D$1,Sheet1!$I$1:$I$100,sheet2!D$1,Sheet1!$J$1:$J$100,sheet2!D$1)
Change ranges according to your requirement, Do take care of the freezing $ sign within the ranges.....once done...drag your formula across and below..
How does Countifs work:
=COUNTIFS(range1,value to find within range1,range2,value to find within range2, range3, value to find within range3.......so on)
Pivot table can solve the above issue.