Copying Multiple Columns from Worksheets to a single Worksheet - vba

I am interested in copying multiple columns from multiple sheets to a single sheet. Basically, I have water utilization data on 22 sheets. Each one of these sheets contains utilization data pertaining to a particular day in the month and all the sheets have the same formatting. So, I am interested in copying the utilization columns (let's suppose I,K,N and P) from each one of these 22 sheets and then paste it in a summary sheet so that I can have the utilization data from each day in a single sheet. The output that i'm looking for on my summary sheet is - (columns I,K,N,P - from Day1); (columns I,K,N,P - from Day2) so on and so forth.
I would appreciate any help in this regard.
Many thanks. :)

In your summary sheet, select A1 and type the equal sign.
select your first day sheet and select K1 and press enter.
(now the value in K1 in Day1 should be in summary sheet cell A1)
In summary sheet, drag A1 down to show all data you need.
Repeat process for all columns in all sheets.
Now you have a working summary sheet that you can copy/paste into your next month summary sheet also instead of repeating the copy/paste process.
PS: Better yet, choose column I and copy column A to the right until you reach the data in column P. Then delete the columns you do not need. You can just copy the Formula in A1 to E1 and change the sheet name in the formula and repeat the process.

You could start by recording a macro while you perform these actions manually, and then look at the VBA generated by the macro to find the areas you'd like to automate. What have you tried so far?

Related

Excel VBA - How to copy rows based on a criteria from multiplesheets into one sheet

I've have a spreadsheet with multiple sheets and a need to copy specific rows based on a criteria (a specific month). So the idea is to be able to loop through the other sheets and copy rows (for example all rows with June in column 1) onto the sheet "Consolidated Data" from all the country files without touching the "Do not include" sheet.
Thank you!
You have to be more specific - do all the country pages look the same? How are you indicating the criteria (i.e. June), and what do you want the consolidated data tab to look like?

Excel - Can not compare two spreadsheets

I have gone through V-look-up guides online but I can not find one that explains what I am looking for. I am trying to avoid manual checking.
What I have:
Two sheets, Sheet 1 and Sheet 2. Both sheets have the same column names (A1:G1) with multiple rows.
Sheet 1 contains my spreadsheet where I update daily. Sheet 2 is the same spreadsheet that is imported from a application (but has hourly updates). Data can change in each row (for some columns) along with additional added/deleted rows. The data is text, dates and numbers (mixture of both too).
I want to run a formula to highlight the changes on sheet 1 (grabbing the updates from sheet 2. Once I find out the formula works correctly, I would like to know how to replace the Sheet 2 updates onto my spreadsheet (Sheet 1).
I am looking for a formula outside of creating a macro (worst case scenario).
Currently I have the following vlook up formula:
=VLOOKUP(A1,sheet2!$A:$A,1,FALSE)
When I run this in another column (lets say in H1 in Sheet 1), it will display "N/A" if that column (A1) in Sheet 2 is not the same. If it is the same, it will write out the column name.
When I use the following formula highlighting all the cells in Sheet 1, I get a values error:
=VLOOKUP(A1:G33,Sheet2!$A:$G,1,FALSE)
How could I apply that formula to the whole spreadsheet (I guess it would apply to both sheets) and have it highlight records in my spreadsheet (Sheet1). Could it also highlight rows that are missing or added?
The data in Column 1 and 2 would never change (they are ticket numbers). Only change that can apply is if ticket is closed, so when I import the updated spreadsheet that row isn't there anymore. If you think there might be a better way to tackle this down, I would like to hear.
Please let me know if I am not clear.
Here are some example screenshots:
Just in case, the formula for the totals are (adjusting the columns for each):
=SUBTOTAL(3,INDEX(C:C,2):INDEX(C:C,ROW()-1))
Sheet 2 is setup very similar. When I import it into excel, the columns are the exact same as Sheet 1, the only difference can be more/less rows (along with the updates for each row).
You can use conditional formatting.

Check if a Cell Value exists in column, return a value in the same row but different column

I have a large sheet of data in Excel that comes from a vendor daily but I only need certain things from this worksheet. I don't want to delete any of the data I don't need as its used by others and I don't want to filter the data for other reasons. I've tried some other Excel formulas I've found from other users questions and they don't quite do what I need them to do.
All of the data from the vendor comes via a text file and through connections that I didn't setup, we use the "Refresh All" button on the Data tab of the Ribbon to import the new data from the text file into Sheet1 on a daily basis.
I have created Sheet2 where I plan to use the data for manipulation. What I am trying to do Sheet2 is look for the value "A" (what we call an account tag) in Column B of Sheet1. If the value "A" is found then output the value of the cell located in Column A (the account number) of the same row that the value "A" was located on. I want it to skip all the rows that don't have an "A" in Column B as there are several other tags in Column B that are not useful to me.
I need to pretty much repeat the same process to pull the accounts balance from Column AA but once I figure out how to do the above I am sure I can use the same method to pull the balance information.
I have attempted to use VLOOKUP, MATCH and a couple other methods but I can't seem to figure out how to do this. Another thing I'm afraid of is if I get the formula right, it is going to give me blank rows on Sheet2 for all of the rows on Sheet1 that don't have the "A" value, which I don't want it to do. I only want Sheet2 to contain the information I need. I have a feeling I might need to do a Macro, but I am not sure where to start.
Thanks,
EDIT as of 05/31/2016
Ok, so I will attempt to clarify this.
Sheet 1:
Data that is Input
Sheet 2:
Data that is Output
If you look at the image of Sheet 1 Column B has what I am going to call Tags. I need excel to look in Column B for any rows that have an A tag and copy the Account number to Sheet 2 (the output sheet) and then look in Column AA and copy the Balance so that my results on a second sheet look like the image I posted in the second image(the output sheet). There is other data I'll be dealing with on sheet 2 but for the purposes of explaining my problem I only need this information.
If you look at Sheet 1 you will notice that the account number is the same for many rows until I reach a new account number which is tagged with another A in column B. So I need excel to ignore all the other rows until it sees another A in column B and repeat the process of collecting the account number and the balance.
I hope this clarified the problem.
Thanks,
One can use the Macro recorder to begin code. You need an operation to record.
If I have some data
Team Points <space> Team
Leicester 81 <space> Arsenal
Arsenal 71 <space>
Spurs 70 <space>
then I can use from the Data ribbon "Advanced" which throws a popup box, where one can select the List range, and a criteria range. Also one can choose for Action the Copy to another location.
Running this I can get
Team Points <space> Team <space> Team Points
Leicester 81 <space> Arsenal <space> Arsenal 71
Arsenal 71 <space>
Spurs 70 <space>

Copying a worksheet in Excel 2013 using VBA to the end of the workbook

I am working in Excel 2013 and am having some trouble. I have researched online all day and can't seem to find anything that solves my problem.
I have an Excel document that consists of 6 sheets:
Format
Summary
1.1 Detail
1.2 Detail
1.3 Detail
1.4 Detail
The 'detail' sheets are formatted all the same. The 'Summary' sheet rolls up all the values from the 'details' sheets and has all kinds of charts and useful information in it. The 'format' sheet is what I created to try to make this document more dynamic and useful for all different kinds of projects. This document is being used for estimating projects, so different projects are going to have different amounts of 'details' sheets.
SO, my goal is to have a blank in the 'format' sheet that asks how many details are needed. When the user types in 5, the code will add a sheet named '1.5 Detail' to the end of the workbook and have it formatted the same as the other 'details' sheets. Is this possible using VBA? Also, is there a way to make the charts and formulas include the new tab when it is added without manually going and adding it to everything?
Thanks in advance!
Let's say you had three detail worksheets named: d_1, d_2, and d_3.
Each has an Excel Table named Labor with a column entitled "Cost". Each Labor table has a unique number of data rows.
On a summary sheet you could sum all of them like so:
=SUM(d_1:d_3!Labor[Cost])
The above will give you the labor cost grand total from all sheets. It is summing all of the rows from the tables and is not dependent on any summary information in the detail sheets.
So if you add a new detail sheet, d_4, then yes the example formula would need to be updated. HOWEVER, there is an old trick to get around this...
Create two additional sheets with the same tables, but with only one row of ZERO values in each table. Call the first one of these sheets "START". Call the second one of these sheets "END". Place START immediately before the first detail sheet, and place END immediately after the last detail sheet. NOW MAKE BOTH INVISIBLE.
Finally change the example formula to:
=SUM(START:END!Labor[Cost])
Now when new detail sheets are added, d_4, d_5, d_6, d_n, no change needs to happen to the formula on the summary sheet, yet all of the new data are included in the summary calculation.
Use ThisWorkbook.Worksheets.Count to count the number of sheets. Then if it is less, use Worksheets.Add and ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count) to add it on to the end.

How to duplicate cell data in excel between rows if the cells are empty when another cell matches

I know the title is really long winded, I will try to explain
I am trying to get Magento products into Zen Cart (background only - shouldn't be relevant).
I have an excel 2010 xls spreadsheet and in it I have a load of product data: skus, prices, categories, etc... you get the idea. I have each of the products along with their data listed once, each with a unique SKU field.
But... Some of these products are in more than one category and the way I am importing, each product needs to be listed multiple times, once for each category.
So, I have done an sql dump which contains two columns; sku and category. I have pasted these values into excel as new rows, so now I have a situation like this (with a lot more entries):
As you can see for each sku (left highlight) there is one entry containing all the data apart from the category (right highlight) and then there is an additional entry for each category it belongs to which contains only the category and sku but none of the other data.
So, what I need to do is some how copy all the data (apart from the categories column) across all cells with the same sku. Does anyone have any idea how I can achieve this without hitting Ctrl+V several hundred times. I realise VBA can probably handle this pretty easily, but I dont have a clue on that front.
Any help greatly appreciated
I hope you’re willing to use a second sheet, and to reference the data rather than actually copying.
On Sheet2, set A1 to =IF(Sheet1!A1="", "", Sheet1!A1).  Drag (extend/fill) this down to A500 (as much data as you have on Sheet1, or further, to allow for growth).  Also drag A1 over to AA1 and then drag that down to AA500.
Then set B2 to =IF($AA2="", Sheet1!B2, B1), drag it to Z2, and drag B2:Z2 down to B500:Z500.
P.S. If any of your data (columns) are dates, you will probably need to explicitly format them as dates on Sheet2.  Ditto for any other values that are formatted any non-default way (e.g., Currency or Percentage).  It may be necessary to do this only to cells that have values in them (and not blank cells).
You don't need VBA, unless you need to do this many times.
Assuming the sheet with your data is called Source and the sheet with the result is called Dest, you can get what you want following these steps on the sheet Dest:
On A1 type =Source!A1
On A2 type =IF(ISBLANK(Source!A2),A1,Source!A2)
Select the range A1:XX1 (where XX is the last column of the sheet Source)
Press Ctrl+R (to copy the first cell to the right)
Select the range A2:XX## (where ## is the last row of the sheet Source)
Press Ctrl+R and Ctrl+D (to copy to the right and down)
Here is an explanation of what's going on:
The first row is copied from the Source as it is.
Each cell of the second row is copied from Source only if that cell is empty, otherwise the cell above is copied.
Here's the quick and dirty solution:
Select the columns you need to be filled
Press Goto Ctrl-G
Special `Alt-S'
Blanks (Alt-K, Enter)
This should select all blank cells. Now type =B2 (assuming you're in B3, i.e. use the cell above the active cell) Important: Press Ctrl-Enter instead of Enter to enter the formula.
Done!
On a new Worksheet get the numbers 1-26 running across the top in Row1 by typing 1 in cell A1, 2 in cell A2, and then selecting those two cells and filling through Z.
Now in A2 type the following formula =VLOOKUP(Sheet1!$A1,Sheet1!$A:$AA,VALUE(A$1),FALSE)
Fill this formula in the Range A2:Z## (where ## represents your last row of data).
Then copy Row1 from Sheet1 to Row1 on Sheet2.
This formula will copy the rows of data straight down into the empty rows below them (assuming the sku only changes where there is a row of new information.
This will then all be active formulas, so I would recommend selecting all on Sheet2 and right-clicking in cell A1, and paste special by value.