![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 1
|
I have a large excel file which contains six months of info. Leads ,Orders ,dollars, customer names ect... . I have a seventh tab which contains all orders that have been closed in the last 6 months. What I want to do is create a macro that will pull out all the customer info in the last six month that match the closed order list on the seventh tab. The end result is that I will have a spreadsheet with all closed customer orders. This info is in 7 different tabs. Can you help?
Thanks |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
Questions:
How many columns in the Monthly data tabs? Which column is the order number? How many columns in the Closed orders tab? Which column is the order number? What do you want the closed orders tab to look like when the macro is finished? (i.e. how many columns, etc.) K |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
While waiting for your response, I worked something up:
Sub CloseOrders() Dim i As Long Dim j As Long Dim k As Long Sheets("Sheet7").Select For i = 2 To 10000 If Cells(i, 1).Value = "" Then Exit For For k = 1 To 6 For j = 1 To 10000 If Sheets(k).Cells(j, 1).Value = "" Then Exit For If Sheets(k).Cells(j, 1).Value = Cells(i, 1).Value Then Cells(i, 3).Value = Sheets(k).Cells(j, 2).Value Cells(i, 4).Value = Sheets(k).Cells(j, 3).Value Cells(i, 5).Value = Sheets(k).Cells(j, 4).Value Exit For End If Next Next Next End Sub This macro assumes the following: 1. Order numbers are in column 1 of the first 6 tabs starting with row 2. 2. Order numbers are in column 1 of the 7th tab (which is called Sheet7). 3. Date closed is column 2 of the 7th tab. 4. Data is in columns 2 through 4 of the first 6 tabs. 5. You have less than 10000 rows in the first 6 tabs. To change to your application, you will need to name the 7th tab to your name and create more lines to move additional data (assuming you have more than 3 columns of data). Let me know if you have problems, K |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|