Switching Two Workbooks And Transferring Data With Variables
Jan 4, 2007
I have create a nice invoice with macros to random insert pages and summations etc. Works fine, but to complete it I want to go one step further and there ìt got out of hand.
I want to create the following, but I can not get al this combined in two Macros.
Basis: Workbook 1 = Invoice, Workbook 2 = Invoicelist
Required actions Macro1:
1. Starting point is that Workbook “Invoice” is open.
2. The user activates Macro1.
3. Check if Workbook “Invoicelist” is active.
4A. If YES then continue,
4B. If NOT then reply with some sort of Alertbox “Invoicelist not active! Click OK to open (needs to open Workbook “Invoicelist” or Cancel to stop (needs to stop Macro).
5. Workbook 2 “Invoicelist” is now open.
6. Find the last invoicenumber in the list. Add “1” and put the new number to the list (to prevent using double numbers). Then I want to take this number to the “Invoice’ workbook, but that can be done by copy and paste.
Now I get really stuck because I want to use variables instead of multiple copy paste actions.
Required actions Macro2:
7. We are in Workbook “Invoice”, the user activates Macro2.
8. Same check if Workbook “Invoicelist” is active as in Macro1.
Several data from “Invoice” has te be transfered to “Invoicelist”. And to be safe, this does not have to be the last cell if the user “forgot” to store date for a previous invoice!
9. Store data from sevaral cells in variables, including invoicenumber!
10. Find invoicenumber in “Invoicelist”.
11. Paste data from variables into fields on same row as correct invoicenumber.
12. Save Workbook “Invoicelist”.
13. Go back to Workbook “Invoice”.
The two problems I cannot fix is checking if Workbook is Active and store and use cell values with variables.
Every month I get sent sales figures of products, from now I have been typing in every sales figure which is long and boring. So I was wondering whether there is a way to make excel match the products on each workbook (mine and the one I get sent) seeing as there is a product number on both workbooks and then have excel automatically fill in the field I type manually which are quantity and value. So excel would see on the one workbook that product X has sold 10 units with 1000 value and then would go across to my workbook and fill that in the area I need on mine matching from the product code?
I have two workbooks with similar columns (note: both workbooks may not have all the same columns, but for the same columns, the names are written identically in both workbooks). I'll walk through what's in each sample workbook I've provided and what I am hoping to accomplish.
Transfer Rows1: This workbook contains multiple rows of data for one company or ID (For example, Client "A Co" has 4 rows of data.)
Transfer Rows2: Contains some of the same columns as workbook 1, but not exactly in the same order.
What I want to do is take all the multiple row data for an ID in Transfer Rows1 and put the information as a single row in Transfer Rows2. So, Client "A Co" in Workbook 1 has 4 rows, but in Workbook 2 will have 1 row. It's matching columns, essentially. Columns that are present in both workbooks should have the data filled out in only ONE row in Transfer Rows2.
As far as cost is concerned, Cost A in Transfer Rows2 is just the sum of all the Cost A's for a particular ID Number in Transfer Rows1 (same for Cost B and Cost C).
I also want the installation date in Transfer Rows2 to be the latest installation date for each unique ID from Transfer Rows1.
Also, a particular client can have multiple CID's. This appears in different rows in Transfer Rows1, but should appear in one row, multiple columns (again, for each unique ID) in Transfer Rows2.
Notice, the column 'Products' in Workbook 1 is not in Workbook 2, and that's because each row for column may have different information and thus I would not be able to transfer it into a single row in workbook 2.
TransferRows1 is where I am right now and I have filled out TransferRows2 to indicate what I hope to accomplish. I am posting here because the actual set I am working is fairly large, on the order of ~ 35,000 rows and need to automate this process using code instead having to copy and paste thousands of times.
From a workbook, I need to open a further workbook called 'transfer' and then switch back to the original workbook. Presumably I need to save the current workbook name to a variable, open transfer with Workbooks.Open Filename:="c:debworkTRANSFER.xls" then switch back to the original
How do i pass the original workbook name to a variable, and then reactivate it. I have tried numerous options but just cannot get it to work. Do i reactivate with workbook. activate or windows.activate
I'm trying to write a piece of VBA code which will switch back and forth between 2 workbooks, but I was hoping that I would not have to name both workbooks in my code.
So far I have been able to name the second file as a variable, open it and copy the data I need, but I now need to switch back to the original file. Is there any way of doing this without hard coding the file name?
I have 3 workbooks open, the main WB has my command button + code in it, and the other 2 were opened up using the existing code in my main workbook.
Using general code e.g( Thisworkbook, activeworkbook, workbooks(1)), how can I activate one out of the 3?
I know the main workbook can be accessed using "thisworkbook", but when I activate it, I can't activate one of the others in my next line of code using activeworkbook.activate, or workbooks(1).activate.
Is there a way to switch back and forth between workbooks without having to use the Activate command? I have everything planned out but this aspect is still a source of confusion. The Project: I need to have qty purchased and price in a table from Worksheet B entered into the matching customer index location in Worksheet A. Worksheet B contains customer number, sku, qty purchased and price. Worksheet A contains customer numbers in row 3 and sku's in column A. Minor data manipulation will need to be done on Worksheet B before before accessing it which I plan to do after opening it in this macro.
I have a folder containing a number of worksheets, these worksheets are of 2 types, a customer submitted workbook and, associated with each of these, anything between 2 and 7 locally created workbooks. I have a macro which opens a customer workbook and all the relevant local workbooks. My problem is that I need to declare a variable for each of the workbooks in the form
Dim N As Integer, WbN As workbook,Wb1 As workbook If activeworkbook. name Like *ALL.xls Then Set wb1 = activeworkbook Else Set WbN = activeworkbook N=N+1 End If
I'm trying to print score cards from the scores sheet (two different worksheet pages). Some score cards (each score card is one page) will only have 3 players and some will have up to 5 players so I can't just go down the list and use a formula to transfer data line by line. I will set the score sheet up I just all of hole 1 players to be printed on a card and so on with hole 2-18 also I need First and Last names on the cards and possibly score total by the name.
I have a workbook, which is having many sheets but I am sending here two sheets only.
Please refer test file.
I want here a 'Add' button which transfer Column C,D,E,F's data to 'EOD' sheet's F,G,H & I. next time when I click 'Add' Button EOD'S f,g,h,I data should shift to j,k,l & m and calci sheet's c,d,e,f's data to eod's f,g,h,&I, and so on.
I am trying to get a macro to update information from attached sheet GTS807 to the Stock sheet. The code in Module 26 works only for the first line and will be very long if I repeat it for the 20 lines of the input sheet! Basically we need to copy the new stock balance from GTS807 column AA13 to AA32 to the individual corresponding product name on the stock sheet (Column E)!
I wanted to : when i write data on one cell (sheet A), i want to see the same i wrote into another cell (sheet B), thts very simple, i know, but when its in blank (Sheet A), in sheet B appears a zero. I dont want to have zero, i want to remain blank as in sheet A.
i did in sheet B "='sheet A'!A117".
i am a noob in VBA, just beginning, and i am loving....
I have somewhat of a complex issue (at least i view it as one).
I have included a sample Excel Doc.
I want to be able to enter data into the spreadsheet titles LIST as i receive it. i receive invoices and checks and i keep a running tally. but i am trying to avoid re-entering the same data into the BREAKDOWN tab. but i need the data to go to the proper place in BREAKDOWN. The problem is that i have no idea how big the list will be and how many invoices i will be receiving. so i think new lines will needed to be inserted in BREAKDOWN when i add to the running total in LIST.
I'm entering some sales data on a worksheet named 'Sales'. Some items are sold on a 'sale or return' basis, and others are not.
What I would like to do is to have all items that are sold on a sale or return basis copied automatically into another worksheet named 'Sale or Return', along with some other data related to that sale. The data transferred would have to be: Date, Agent, Item, Units, Date of return. I would like the data to be transfered into consecutive rows in the 'Sale or Return' sheet. After some Googling I'm vaguely aware this may have something to do with VLOOKUP.
The challenge I'm having is that there may be one sale or return entry for every ten rows of data on 'Sales' yet I would like them to appear consecutively in 'Sale or Return'.
I am trying to have an entire line of data copied into another tab depending on the status of a claim. For instance, if the claim on Tab A has a column for its status and I enter approved, then the entire line is copied and added to the tab for all approved claims (Tab B). If I enter denied, I want it to go to a different tab (Tab C), and and if I enter pending, yet another tab (Tab D).
Basically i want to be able to look at Tab A and see a complete list of all claims but then be able to click to Tab B and see an list of all approved claims, and so on.
I am trying to combine rows of data, each 4 cells long from multiple worksheets into one master sheet. I need to know if there is an easy way to do this and also I would like to setup an Auto Sort if possible to automatically sort the rows by date.
The data that will be transferred is: Date, Amount, Description, and Company Billed. I have my workbook organized by a Vendor per worksheet and would like to have the data I enter inside the vendor worksheet to automatically transfer to the master sheet and sort by date.
We have database (attached here). I want to copy the name of candidates base on their Status to their designated tab. example Diana Longoria name will be copy to "Waiting" Tab and if I change the status to "Rejected" it will be copied to "Rejected" tab and remove name from "Waiting" tab.
I'm not sure that this is possible without VBA, but here goes.. My sample workbook has 3 sheets. 'Master' Sheet A contains fields that are to be completed manually as our sales people talk to prospective customers. Once that information has been input, I'm trying to find a way to have the contact information (columns B - L) to copy automatically to either (in this example) to sheets B or C depending upon the chosen category in Column A, Sheet A. An example is that the sales adviser inputs the information into sheet A and then gives each row of information a category, say B, which then copies the required fields into Sheet B, at the next available row.
I have a workbook with two sheets of sku numbers. One sheet has sku numbers and prices, the other just has sku numbers but some of the sku numbers on the second list have been broken out by sizes. I need to take the prices from the first list and transfer them to the matching sku numbers on the second including the ones with multiple of the same sku but with prices. Also, not all of the skus from the second list are on the first list so I only need to do the ones that occur on both lists. There are over 3000 on the first list and 14000 on the second. What is the fastest way to accomplish this.
I tried to sort so that all the sku's in both sheets are in the same order then copy and paste the price to the matching sku on the second sheet and then drag the price down through the sizes on the ones that have different sizes (not all of them do) but I know there must be a faster way.
What I am wanting to do is to transfer Names(Row B7:B160) to a different work sheet IF the Row next to it(C7:C160) is filled out with a time. I will be setting up a command button that once say 10 names have times next to it, this data then will transfer to another work sheet.
I have done below coding, however it will only transfer data in B7 and C7, if I try to add B7:B160 it comes back as Missmatch. Below is what I have done for the Command button.
Private Sub CommandButton1_Click() Dim AdviserName As String, Time As Integer Worksheets("Sheet1").Select
I have a userform with texts boxes and comboboxes. I have a button at the bottom of the form which when pressed I want the data from these text boxes etc to transfer to the next empty row in excel. Eg I want textbox1 to be in cell A2, textbox2 to be in A3 and so on. How I would do this?
I have made a cash register in excel with a cell that counts the total of all cash coming in per day whenever you push the button with "payed". I have another sheet where there is a column with all the days of the year. What is the correct syntaxis for transferring the total cash to the cell next to the right date in the other sheet every time i push the "payed" button (am I making any sense...?). And is there a way to reset the total amount back to zero automatically whenever the day changes?