I have a worksheet with over 3 months worth of data entry. My coworker claims she can't understand the layout. She wants me to change it from example 1 to example 2. Is there any easy way to do this without re-entering 3 months worth of work?
Example 1
WK# | DATE | ACCT NAME
1 | 7/09/15 | MY PLACE
2 | 8/06/15 | MY PLACE
3 | 8/13/15 | MY PLACE
4 | 8/20/15 | MY PLACE
5 | 8/27/15 | MY PLACE
Example 2
Acct Name | Wk 1 | Wk 2 | Wk 3 | Wk 4 | Wk 5 |
-----------|-----------|-----------|------------|-----------|-----------|
My Place | 7/9/15 | 8/6/15 | 8/13/15 | 8/20/15 | 8/27/15 |
Yes, it can be done.
For every processing worksheet:
Create new worksheet
Populate layout (header) cells of new created worksheet
Read cell values from old worksheet and put these values to the new worksheet cells.
Related
I have an excel workbook where I am trying to count the number of apples in a named table. The workbook has multle sheets each named Jan, Feb, Mar, etc. with a corresponding table range of the same name.
My main worksheet has a list of months as columns and fruit as rows, I want to use a countif or suitable function to count the number of each fruit per month using the column heading as the worksheet portion of the formula.
This is what I have tried, this works, but has to be manually coded for each month, i would prefer it be more dynamic.
=COUNTIF(JAN[Labels],$A2)
Note: A2 contains the word apple
I have tried to get the month from the column date but it doesnt work
=COUNTIF(TEXT(E25,"mmm")[Labels],$A2)
This is roughly what the "master" table should look like (for clarity)
| | Jan-20 | Feb-20 | Mar-20 | .... |
| Apple | 4 | 3 | 5 | ... |
| Pear | 5 | 4 | 9 | ... |
EDIT:
Just to assist with anyone trying to help, this is roughly what a table on another sheet will look like:
| invoice | labels|
| 12535 | Apple |
| 12536 | Pear |
| 12537 | Apple |
This table would be a named table of Jan or Feb, etc.
Please try this:-
=COUNTIF(INDIRECT(TEXT(G2,"mmm")),"A")
G2 contains a proper date.
Here is a variation of the above where column 2 of the table is specified as the range to count in.
=COUNTIF(INDEX(INDIRECT(TEXT(G2,"mmm")),0,2),"B")
If you must use column captions to identify the column I would suggest MATCH to find it.
OK, so I found an answer, combining the above answer by Variatus with an additional new row.
| A | B | C | D |
1| | Jan-20 | Feb-20 | Mar-20 |
2| |JAN[Labels]|FEB[Labels]|MAR[Labels]| <- =UPPER(TEXT(B1,"MMM"))&"[Labels]"
3|Apple | 5 | 7 | 3 | <- =COUNTIF(INDIRECT(B$2),$A3)
4|Pear | 7 | 2 | 9 |
5|Orange| 1 | 3 | 3 |
So formula in B2 makes an uppercase text value of the month from B1 plus the column name Labels.
The formula in B3 (and down) counts the number of instances of the fruit from the named table & column shown in B2.
I have two excels workbooks, let's say, wb01 and wb02. Suppose they have only one sheet, sh01 and sh02 respectively.
I need to synchronize sheets (sh01 and sh02) by copying the cell values (name and surname columns) from sh01 to sh02 when "Id" column match.
Example
sh01 in wb01
Id | name | surname | Dept
10 | John | McCoy | Logistics
21 | Liam | Alloy | Administration
40 | Peter | Gregor | Finance
42 | Albert | Kein | Business
50 | Kelly | Braxton | Logistics
60 | Isabella | O'Neill | Finance
sh02 in wb02
Id | name | surname | ext.
10 | David | McCoy | 1004
23 | Bren | Summer | 1230
40 | George | Brown | 2400
42 | Astrid | Anderson | 3312
50 | Kelly | Braxton | 1139
51 | Evelyn | Connor | 4532
I do not need to copy these cell values from sh02 to sh01, only from sh01 to sh02.
Also if "Id" cell value exists on wb01 but not in sh2, cell values name and surname should be copied to sh02 as a new row and the rest of fields must be kept empty/blank in sh02.
Taken into account above two sheets, after copying process, sh02 must be as below:
Id | name | surname | ext.
10 | John | McCoy | 1004
21 | Liam | Alloy |
23 | Bren | Summer | 1230
40 | Peter | Gregor | 2400
42 | Albert | Kein | 3312
50 | Kelly | Braxton | 1139
51 | Evelyn | Connor | 4532
60 | Isabella | O'Neill |
This copy process should be done on demand, I mean, when user clicks a button from sh02 in wb02. On button click, a macro in sh02 will be executed to start the copying process from sh01 to sh02.
You've literally not provided any code that you've attempted to use to do this, more people would gladly help if you would have at least attempted to code it...
Nonetheless, you did not provide your sheet names, here is some code you can put to the test.
Sub CopyValue
Dim Wb1 As Workbook, wb2 As Workbook, lastrow As Long, lastrow2 As Long, counter As Integer
counter = 0
Set wb1 = Workbooks("wb01")
Set wb2 = Workbooks("wb02")
lastrow = wb1.Range("A" & .Rows.Count).End(xlUp).Row
lastrow2 = wb2.Range("A" & .Rows.Count).End(xlUp).Row
For x = 2 To lastrow
For y = 2 To lastrow2
If wb1.Sheets("abc").Cells(x,1).Value = wb2.Sheets("def").Cells(y,1).Value Then
wb2.Sheets("def").Cells(y,2).Value = wb1.Sheets("abc").Cells(x,2).Value
wb2.Sheets("def").Cells(y,3).Value = wb1.Sheets("abc").Cells(x,3).Value
Else
counter= counter +1
wb2.Sheets("def").Cells(lastrow+counter,1).Value = wb1.sheets("abc").Cells(x,1).Value
wb2.Sheets("def").Cells(lastrow+counter,2).Value = wb1.sheets("abc").Cells(x,2).Value
wb2.Sheets("def").Cells(lastrow+counter,3).Value = wb1.sheets("abc").Cells(x,3).Value
End If
Next y
Next x
End Sub
I have a table of data, and some of the data is garbage. There's about 30000 entries sorted by unit. I only care about 20 of those units. I can easily sort the data by applying a filter, but it's tedious to click the 23 or so times and I'm going to have to manage this report weekly.
I've captured the relevant criteria into a different sheet, all non-repeating values sorted into a column. I'd like to arrange another sheet so that it only displays the rows from my table if the data in their unit column matches the criteria column.
I know I need to use VLOOKUP... somehow, but I haven't stumbled across any tutorials that compare a cell's value to a table.
In case that was all very confusing:
My table:
Action | Job Desc | Dept
XFR | IT Guy | Home Office 1
POS | Security Guy| Satellite Office
TTL | Analyst Guy | Home Office 2
I want to have a new sheet that only contains 3 rows:
Action | Job Desc | Dept
XFR | IT Guy | Home Office 1
TTL | Analyst Guy | Home Office 2
I have the values "Home Office 1" and "Home Office 2" stored elsewhere (there are actually 28 different office values). How do I build this sheet so it only displays these values - similar to the stock Excel filter function?
I think the easiest way to do this is by creating a tab of "interesting" units and vlookup to this. In the new interesting tab you would list the 20 items you are interested in column A.
In the data tab with all 30,000 rows you need to add a new column to check each row if it exists in the interesting tab. I assume the units are in column C and you are entering this formula in cell D1 =NOT(ISERROR(VLOOKUP(C1,InterestingTab!A:A,1,0))).
The result of the formula is TRUE or FALSE, which can easily be filtered on. Then you can easily add new items to the interesting tab and it will update automatically.
A very common question.
Assuming that:
1) You are using Excel 2010 or later
2) The original table is in Sheet1!A1:C10 (with headers in row 1)
3) The table to house the (filtered) results is in Sheet2 and of an identical layout to the original table
4) The list of (28) criteria is in Sheet3!A2:A29
then enter this single formula in Sheet2!J1:
=SUMPRODUCT(COUNTIF(Sheet3!A2:A29,Sheet1!C2:C10))
Of course, the choice of cell here does not have to be J1, though, whatever you choose, make sure that it is a cell which is external to your results table. This formula is a one-off, and, unlike those in the main results table, NOT designed to be copied to any further cells; it simply determines the number of expected returns, and will be referenced in the main table formulas, thus avoiding resource-heavy IFERROR set-ups.
The formula in cell A2 of the results table is then:
=IF(ROWS($1:1)>$J$1,"",INDEX(Sheet1!A:A,AGGREGATE(15,6,ROW(Sheet1!B$2:B$10)/MATCH(Sheet1!$C$2:$C$10,Sheet3!$A$2:$A$29,0)^0,ROWS($1:1))))
and copied down and to the right as required.
Obviously if the upper row reference in your original table is not actually 10 then you will need to amend that part within these formulas accordingly. However, be sure not to choose an arbitrarily large value, since, for each additional cell referenced, extra calculation will be required (and that applies whether those additional cells are technically beyond the last-used cells in those ranges or not.)
As such, I recommend that you either choose a suitably low, though sufficient, upper bound for the end row being referenced or, even better, make your ranges dynamic, such that they automatically adjust as your data expands/contracts.
Regards
Here is my anser...
Sub takeMyValus()
Dim r1
Dim r2
Dim c
Dim rng1 As Range
Dim rng2 As Range
Dim sht1 As Worksheet
Dim sht2 As Worksheet
Dim sht3 As Worksheet
Dim List()
Dim i
Dim j
r1 = Range("A1").End(xlDown).Row 'to know the last row
c = Range("A1").End(xlToRight).Column 'to know the last colum
Set sht1 = Sheets("Data") 'this is the name I used, but you
'put the name of your data sheet
Set sht2 = Sheets("List") 'the sheet with the sorted list of the data you want
sht1.Activate 'Just in case
Set rng1 = Range(Cells(1, 1), Cells(r1, c)) 'set just the range with data
rng1.AutoFilter 'set the autofilter
'is better if the data has no autofilter
'when you begin to run the macro
sht2.Activate
'imagine that you got the list in column A and is just 5 items in your data
'With no header
'+---------+
'| Office3 |
'| Home5 |
'| Office8 |
'| Home8 |
'| Sat2 |
'+---------+
'List for my example...
r2 = Range("A1").End(xlDown).Row 'to know the total item on the list
'in this case will be 5
Set rng2 = Range(Cells(1, 1), Cells(r2, 1)) 'set the range of the list
'that is Range("A1:A5")
j = 0 'ini the counter
For Each i In rng2 'for every cell in Range("A1:A5")
j = j + 1 'increase the j to 1 every time
ReDim Preserve List(1 To j)
'redimension the var...
List(j) = i.Value 'store every cell (just the data) into an array
Next i 'next one.
sht1.Activate 'go to sheet with all the data
rng1.AutoFilter Field:=3, Criteria1:=Array(List), Operator:=xlFilterValues 'set the filter with the list
rng1.SpecialCells(xlCellTypeVisible).Copy 'copy just the cells that you can see, this is the filter
Sheets.Add after:=Sheets(Sheets.Count) 'add a new sheet
ActiveSheet.Name = myTime 'put a diferent name, see the function below
Set sht3 = ActiveSheet 'store the new sheet into this var
sht3.Activate 'go to the new sheet... is already activate, but just in case...
Range("A1").PasteSpecial xlPasteAll 'paste all in Range("A1")
Application.CutCopyMode = False 'is like press ESCAPE in the keyboard
End Sub
Function myTime() As String 'the function a told you
Dim HH
Dim MM
Dim SS
Dim TT
HH = Hour(Now)
MM = Minute(Now)
SS = Second(Now)
myTime = Format(HH, "00") & Format(MM, "00") & Format(SS, "00")
End Function
Here is the example of my data...
+--------+---------+----------+
| Action | Job Des | Dept |
+--------+---------+----------+
| XFR | IT | Office1 |
| POS | Sec | Office2 |
| TTL | Analyst | Office3 |
| XFR | IT | Office4 |
| POS | Sec | Office5 |
| TTL | Analyst | Office6 |
| XFR | IT | Office7 |
| POS | Sec | Office8 |
| TTL | Analyst | Office9 |
| XFR | IT | Office10 |
| POS | Sec | Home1 |
| TTL | Analyst | Home2 |
| XFR | IT | Home3 |
| POS | Sec | Home4 |
| TTL | Analyst | Home5 |
| XFR | IT | Home6 |
| POS | Sec | Home7 |
| TTL | Analyst | Home8 |
| XFR | IT | Home9 |
| POS | Sec | Home10 |
| TTL | Analyst | Home11 |
| XFR | IT | Home12 |
| POS | Sec | Sat1 |
| TTL | Analyst | Sat2 |
| XFR | IT | Sat3 |
| POS | Sec | Sat4 |
| TTL | Analyst | Sat5 |
| XFR | IT | Sat6 |
| POS | Sec | Sat7 |
| TTL | Analyst | Sat8 |
| XFR | IT | Sat9 |
| POS | Sec | Sat10 |
| TTL | Analyst | Sat11 |
| XFR | IT | Sat12 |
| POS | Sec | Sat13 |
| TTL | Analyst | Sat14 |
+--------+---------+----------+
The list
+---------+
| Office3 |
| Home5 |
| Office8 |
| Home8 |
| Sat2 |
+---------+
The result:
+--------+---------+---------+
| Action | Job Des | Dept |
+--------+---------+---------+
| TTL | Analyst | Office3 |
| POS | Sec | Office8 |
| TTL | Analyst | Home5 |
| TTL | Analyst | Home8 |
| TTL | Analyst | Sat2 |
+--------+---------+---------+
I am trying to populate one worksheet (summary) with data from a large data dump held in another worksheet (data).
This is going to be sent to budget holders within my organisation who will be able to filter on their cost centre and view their staff group.
Summary worksheet
This is structured as follows:
| | A | B | C | D |
| 1 | Please choose a cost centre: [Textfield] |
| 2 | | | | |
| 3 | POSITION | STAFF GROUP | PAY GRADE | |
| 4 | [Data will go here]
| 5 | [Data will go here]
| 6 | [Data will go here]
Data worksheet
This is structured as follows (although with 3,600 rows and not 4):
| | A | B | C | D |
| 1 | POSITION | STAFF GROUP | PAY GRADE | COST CENTRE |
| 2 | Typist | A&C | Junior | 3000 |
| 3 | Manager | A&C | Mgmt | 3200 |
| 4 | Typist | A&C | Junior | 3000 |
| 5 | Receptionist | A&C | Junior | 3000 |
The Exam Question
Using the textfield to select cost centre 3000, how can I populate the Summary worksheet with the two rows of data from the Data worksheet? Almost as if you could through a pivot table. Could this be done with formulae or will VBA be required?
METHOD #1
This is the formula way to achieve the filter.
On the Summary sheet, select the range A4:C22.
Click the Formula Bar at the top of the worksheet and paste the following formula:
=IFERROR(INDEX(Data!A2:C22,SMALL(IF($D$1=Data!$D$2:$D$22,ROW(Data!$D$2:$D$22)-ROW(Data!$D$2)+1),ROW()-3),{1,2,3}),"")
This is an array formula and must be confirmed with Ctrl+Shift+Enter.
Now, as you update the value in cell D1, the filtered results will appear.
Note: this assumes that you will have no more than 20 filtered results. If that assumption is incorrect then you will need to select a deeper range before you confirm the array-formula.
Note: this assumes that the data on the data sheet do not extend further down than row 22. If the data do, then change the references of 22 in the formula to a larger number.
METHOD #2
This is a VBA soltuion.
Place the following procedure in a standard code module:
Public Sub Barry()
Const DATA = "data!a1"
Const OUTPUT = "a3:c3"
Const FILTER_VALUE_ADDRESS = "d1"
Const FILTER_COLUMN = 4
Dim rCrit As Range, rData As Range
Set rData = Range(DATA).CurrentRegion
Set rCrit = rData.Resize(2, 1).Offset(, rData.Columns.Count + 2)
rCrit(1) = rData(1, FILTER_COLUMN): rCrit(2) = Range(FILTER_VALUE_ADDRESS)
rData.AdvancedFilter xlFilterCopy, rCrit, Range(OUTPUT)
rCrit.Clear
End Sub
Switch to the Summary sheet and press Alt-F8 to bring up the Macro Dialog.
Run Barry.
In one spreadsheet document, file.xlsx, I have 2 sheets. Sheet1 has the editable fields. Sheet 2's sole purpose is to read the data from Sheet1.
The point is to keep track of inventory and easily display items needed to be ordered.
Sheet1 'column a' is item number for ordering
Sheet1 'column b' is the number I have on hand
Sheet1 'column c' is the formula cell to find the number needed to be ordered
It looks something like this:
Document1:sheet1
A | B | C |
1 |txt1 | 1 | =10-b1 |
2 |txt2 | 0 | =10-b2 |
3 |txt3 | 13 | =10-b3 |
4 |txt4 | 5 | =10-b3 |
5 |txt5 | 2 | =10-b4 |
There is some if statement conditional formatting in the "C" column to check if the "B" column has a value HIGHER than 10 and if it hits true then the corresponding C cell is blank but for space, i'm summarizing here
Document1:sheet2
A | B |
1 |=if(sheet1!C1>0,Sheet1!A1,"") |=if(sheet1!C1>0,Sheet1!C1,"") |
2 |=if(sheet1!C2>0,Sheet1!A2,"") |=if(sheet1!C1>0,Sheet1!C2,"") |
3 |=if(sheet1!C3>0,Sheet1!A3,"") |=if(sheet1!C1>0,Sheet1!C3,"") |
4 |=if(sheet1!C4>0,Sheet1!A4,"") |=if(sheet1!C1>0,Sheet1!C4,"") |
5 |=if(sheet1!C5>0,Sheet1!A5,"") |=if(sheet1!C1>0,Sheet1!C5,"") |
If an item isn't to be ordered because stock is high, it doesn't show up in the list. This is ok. It looks like this:
Document1:sheet2
A | B |
1 | txt1 | 9 |
2 | txt2 | 10 |
3 | | |
4 | txt4 | 9 |
5 | | |
What I would like to see is:
Document1:sheet2
A | B |
1 | txt1 | 9 |
2 | txt2 | 10 |
3 | txt4 | 9 |
4 | | |
5 | | |
For 5 Items in the example, it doesn't seem that annoying, but in actuality I have 1200 potential rows and it varies between 200 to 800 actually populated each time i conduct inventory. The whole point is to have one continuous section of rows that I can select and print. Maybe some way of autosorting and placing the empty ones on the bottom?
I've taught myself excel. I don't know the advanced tricks and things.
I'm a typically a programmer but I've been tasked with this project and the guys upstairs want me to do it in excel.
i've overcomplicated this, to the max.
a simple sort putting the empty's at the bottom is the resolution.
not quite as automated as i'd like
but
it works.