Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
hi Jeremy
Were your sheets called Sheet1 and Sheet2? If not, change the names where it says Source and Destination to match your sheet names -- Regards Roger Govier "Jeremy" wrote in message ... I was not able to get this to work. "Roger Govier" wrote: Hi Jeremy The following code will do what you want Sub Consolidate() Dim i As Long, lr As Long Dim wss As Worksheet, wsd As Worksheet Dim rng1 As Range, rng2 As Range Application.ScreenUpdating = False Set wss = ThisWorkbook.Sheets("Sheet1") ' Source Set wsd = ThisWorkbook.Sheets("Sheet2") 'Destination lr = wsd.Cells(Rows.Count, "A").End(xlUp).Row If wss.AutoFilterMode = False Then If wss.Range("A1") < "" Then wss.Rows("1:1").Insert Shift:=xlDown End If wss.Range("A1:B1").AutoFilter End If For i = 1 To lr Selection.AutoFilter Field:=1, Criteria1:=wsd.Cells(i, 1).Value Selection.AutoFilter Field:=2, Criteria1:=wsd.Cells(i, 2).Value Set rng1 = wss.AutoFilter.Range.Columns(3).Cells Set rng1 = rng1.Offset(1, 0).Resize(rng1.Rows.Count - 1, 1) Set rng2 = rng1.SpecialCells(xlVisible) rng2.Copy wsd.Cells(i, 3).PasteSpecial Paste:=xlPasteValues, Transpose:=True Next i Application.ScreenUpdating = True End Sub Copy the Code above Alt+F11 to invoke the VB Editor InsertModule Paste code into white pane that appears Alt+F11 to return to Excel To use Select sheet containing the PT's Alt+F8 to bring up Macros Highlight the macro name Run -- Regards Roger Govier "Jeremy" wrote in message ... I have a rather large database with two sheets of data. I want to take sheet two and put the data in column C to sheet one column C where A and B match on both sheets. Sheet One A B C 1 100 4 2 200 1 3 200 2 4 200 5 Sheet Two A B C 1 100 4 CAR12 2 100 4 WIL13 3 100 4 CAR14 4 200 1 CAR15 5 200 1 CAR16 6 200 2 CAR17 7 200 5 WIL18 What the result should look like A B C 1 100 4 CAR12; WIL13; CAR14 2 200 1 CAR15; CAR16 3 200 2 CAR17 4 200 5 WIL18 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Duplicate sheet, autonumber sheet, record data on another sheet | Excel Worksheet Functions | |||
Hyperlinking from data in one sheet to matching data in another sheet | Excel Worksheet Functions | |||
How can i copy data from a tabbed working sheet to a summary sheet | Excel Discussion (Misc queries) | |||
create a formula in one sheet that would read data from separate sheet automatically | Excel Discussion (Misc queries) | |||
pull data from sheet two, then fill in the data to sheet one (part | Excel Worksheet Functions |