Automatically populate data from active excel worksheet to another - vba

I have a table of targets vs accomplishments per quarter. I have a 1st quarter and 2nd quarter worksheet. What I want to achieve is every time i put data to the 1st quarter on 1st quarter worksheet, it automatically populate the columns/rows in the 2nd quarter worksheet. Please see attached screen shots.

If I understand correctly, you want to have the Q1 cells populated in the Q2 worksheet with the values you enter in Q1 sheet.
Can't you simply put a reference to the cell in Q1?
='Q1SheetName'!CellAddress

You may use Excel formuar to link value,e.g. in Sheet2 cell C11 =Sheet1!B11

Related

vlookup to pick the nearest date lesser date from the reference cell

I required your support,
I have a datasheet (Sheet1) which is having product details and its dates which are been imported. Another sheet (Sheet2) which are also having product details and its dates which are been exported by the seller. Both the sheet dates might not be equal nor the total no. of rows will be the same.
I wanted to understand if a Vlookup can compare the dates of sheet 1 & sheet2 for each product keeping the imported dates of sheet 1 as a reference and pull the nearest lowest date from the sheet2 "created date"
Sheet 1 is having the data which is from imported data
Sheet 2 is the date which shows the actual export from the seller
So now I need to do a comparison for the Product bearing (cell A2) from Sheet 1, which is having the imported date as of 10/22/2019. Comparing to the next Sheet2 (Image 2 ) for the same product bearing which is having the created dates as 10/18/2019, 11/08/2019,10/16/2019.
The formula should now pick a date which is nearest lesser to the imported date which is in the sheet1. in this case, formula to pick the date 10/18/2019.
I tried to sort the data to lowest to highest and highest to lowest, but v-lookup results were not always right. I tried to insert the IF condition resulted in no luck.
It would be very helpful if you all share some insight into this case.
Thank you for reading the above case.
Use AGGREGATE:
=AGGREGATE(14,7,B2:B100/((A2:A100="Bearing")*(B2:B100<=Date(2019,10,22)),1)

How to set the value of a cell depending of 2 other criteria

I have an Excel tab like this.
It give me information on when a worker is plan to start on a product.
The Columns of my input Table are:
Product Number, Dummy column, Dummy column, Worker ID, Starting Date, Ending Date
The lines in my input Table are:
Product 1,xyz,xyz,Worker 1,13/08/2018 13:50,20/08/2018 15:30
Product 1,xyz,xyz,Worker 2,08/08/2018 03:50,16/08/2018 08:30
Product 1,xyz,xyz,Worker 9,23/08/2018 08:08,03/09/2018 10:00
Product 2,xyz,xyz,Worker 4,10/08/2018 13:50,27/08/2018 15:30
Product 2,xyz,xyz,Worker 9,18/08/2018 03:50,20/08/2018 08:30
Product 3,xyz,xyz,Worker 2,13/08/2018 08:08,13/09/2018 10:00
My Result table should have:
one line per Worker
one Column for each day of the year
The values in the Result Tab should show for a given Worker and a Given Date on which Product the Worker started to work.
So the cell could be empty if at this date the workerX didn't start to work on a product.
Do you have an idea how I can solve this in Excel (or Access if not possible in Excel)?
Access is probably going to be your best bet. You will want to create a column that strips the time value from the Starting Date column, leaving you with only the day value. Let's call that the Starting Day for now. Now create a crosstab query based on your table. The rows will be based on the Worker ID column. The columns will be based on the Starting Day column. The value will use the aggregate function called "First()" on the Product Number field.
I think it should look something like this in SQL (replace <YOURTABLE> with your table name):
TRANSFORM First([Product Number])
SELECT [Worker ID] FROM <YOURTABLE> GROUP BY [Worker ID]
PIVOT [Starting Day]
Good luck!
Transfer your data in column A.
In cells C2 to C20, type the names of the workers Worker 1, Worker 2, etc, in the same way as it is present in the data.
In row 1, enter the dates, starting from cell D1.
In my example, cell D1 is 7 Aug 2018, E1 is 8 Aug 2018., …
In cell D2, enter the following Array Formula
=IF(MAX(IFERROR(FIND($C2&","&TEXT(D$1,"dd/mm/yyyy"),$A$1:$A$1000,1),0))=0,"-","Yes")
Array Formulas are entered using Control + Shift + Enter, instead of Enter.
Drag the formula to the required cells.
The result will be "Yes" if a worker has started a project on a particular date, and "-" if no project has been started by a worker on a particular date.
Change the cell references as required.
In place of "Yes", if you want to get the Product details as the result, then use the below Array Formula in cell D2.
=IFERROR(LEFT(IF((MAX(IF(IFERROR(FIND($C2&","&TEXT(D$1,"dd/mm/yyyy"),$A$1:$A$1000,1),0)>0,ROW($1:$1000),"-")))=0,"-",INDEX($A$1:$A$1000,(MAX(IF(IFERROR(FIND($C2&","&TEXT(D$1,"dd/mm/yyyy"),$A$1:$A$1000,1),0)>0,ROW($1:$1000),"-"))),1)), FIND($C2,IF((MAX(IF(IFERROR(FIND($C2&","&TEXT(D$1,"dd/mm/yyyy"),$A$1:$A$1000,1),0)>0,ROW($1:$1000),"-")))=0,"-",INDEX($A$1:$A$1000,(MAX(IF(IFERROR(FIND($C2&","&TEXT(D$1,"dd/mm/yyyy"),$A$1:$A$1000,1),0)>0,ROW($1:$1000),"-"))),1)),1)-2),"-")
Do let me know if this is what you wanted to do.
Regards,
Vijaykumar Shetye,
Spreadsheet Excellence,
Panaji, Goa, India

Readjust Pivot data using if statement

Currently have data for each month in a separate tab (eg. January data in Tab "January"...) Have pivot tables preformatted in last few tabs. First Tab has a drop down which has all the months. User chooses a month, VBA macro fills pivot table with data from selected month's tab.
If "January" selected from drop down
Then format pivot tables using "January" tab data
Any assistance in how to structure the VBA code would be appreciated. Thank you.
If the data in each of the month sheets have named ranges, you could use the following code once the month is selected on the first tab:
Sheet("YourPivotTableSheet").PivotTables("PivotTable1").changePivotcache
ActiveWorkbook.Pivotcaches
.create(SourceType:=xlDatabase, SourceData:="YourNewNamedRange", Version:=6)

Loop that changes a date, copy & pastes resulting data, then continues these processes

I have a workbook with 2 sheets. Sheet 1 has a column with a series of dates that are the same day in a sequence of years (for example 5/1/1986, 5/1/1987, 5/1/1988, ... 5/1/2017).
When the first date at the top of the column is changed (for example from 5/1/1986 to 5/2/1986), all of the other years below will update to that given day and a series of data will be produced in two separate columns through a calculation that is depends on the day as a variable.
The 2nd worksheet has two tables where I need the data resulting from each day between 5/1 and 8/28 for 1986 - 2017 to be pasted from the 1st worksheet after the date is changed (5/1 to 5/2 to 5/3) and so on. The tricky part is the copy and paste needs to happen each time before the date is changed in order to record all of the subsequent data.
I know that I will likely need to use a DateAdd function to loop the addition of one day to the starting date at the top of the column, and I know that I will probably need to utilize a Do Until function to have the sequence stopped when the final date of 8/28 is input. I have been tweaking around the code but I cannot get the formatting correct.
To clarify I need a loop that will do two processes, add one day to 5/1/1986 (until 8/28) and copy the data that each change of day yields and paste it into a 2nd worksheet, before the date is changed again and new data appears. Thanks.
Below is the code I wrote that successfully sets up the first step of the process, setting the start date to 5/1/1986 and copying and pasting the data into the tables in sheet2.
'StartDate is input as 5/1/1986 and plugged into first cell of data range, DK7'
Dim StartDate As String
StartDate = Range("DO50").Value
Range("DK7").Value = StartDate
'EndDate is input as 8/28/1986 and used as reference to end sequence of Copy & Pasting'
Dim EndDate As String
EndDate = Range("DO51").Value
'Corn Z-Score results for StartDate are copied and pasted into Sheet2'
Range("DS7:DS38").Copy
Worksheets(2).Range("D4:D36").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
'Soy Z-Score results for StartDate are copied and pasted into Sheet2'
Range("DT7:DT38").Copy
Worksheets(2).Range("D41:D73").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

Filter rows by date (A column) and write sum (C column) to field in another sheet

I have two sheets in Google Spreadsheet document. The first one has columns Month, Income, Expense and Profit (A,B,C,D respectively) and in each row expense value should be calculated based from filter (I think) from another sheet called Expenses.
The Expenses sheet contains columns Date, Name and Price.
So, what I need is to write formula to filter only expenses for specific month, to sum all prices in those rows and to write that value to C column (row for that month) in first sheet.
You can see this example and please help me out to solve this.
This is a formula that can be filled down (I have entered it in F2):
=ArrayFormula(SUMIF(TEXT(Expenses!A$2:A;"MMMM");A2;Expenses!C$2:C))
This is a formula that will automatically populate results down the column (I have entered it in G2):
=ArrayFormula(IF(LEN(A2:A);SUMIF(TEXT(Expenses!A2:A;"MMMM");A2:A;Expenses!C2:C);IFERROR(1/0)))
And this formula will take the year into consideration; I have entered it in J2, referencing month-year strings in I2:I:
=ArrayFormula(IF(LEN(I2:I);SUMIF(TEXT(Expenses!A2:A;"MMMM yyyy");I2:I;Expenses!C2:C);IFERROR(1/0)))