Linda
Here is a macro to get this thing started. Try it out on a copy
of your real file and we'll go from there. The following
assumptions/conditions are built in to this code. By this I mean that you
cannot change these things in your file without making the necessary changes
to the code or the code will no longer work properly. Just let me know what
you want changed.
There is only one file.
There is a sheet named "Final". It has the long list, headers in row 8,
data starts in row 10. Everything starts in Column A.
There is a sheet named "Imported Data". You would place the imported data
into this sheet. Header and data locations are the same as the Final sheet.
In each cycle (each time you import data and run this macro) the data is
pasted to the Final sheet in the column that is one column to the right of
the far right entry in row 10. There is no blank column between column sets
of data.
As written now, the column headers in the Imported Data sheet are NOT copied
to the Final sheet. Let me know if you want them copied/pasted.
After transferring all the data from one sheet to the other, the code clears
all the data in the Imported sheet from row 10 down.
It doesn't matter how many other sheets the file has.
In the event that a company is listed in the Imported Data sheet BUT NOT IN
THE FINAL SHEET, a message box will pop advising you of such and telling you
the company name, and that the program will continue with the rest of the
data.
Note that all these things can be changed by simply changing the
code, so don't feel like your hands are tied in any way.
These newsgroup posts can wrap the text of the code, so be sure
that you view this post in full screen. If you still have a wrapping
problem, we can exchange emails and I can send you a small file with the
code in it. Let me know. Otto
Sub TransferData()
Dim rFinalA As Range
Dim rImportA As Range
Dim i As Range
Dim DestCol As Long
Dim DestRow As Long
Application.ScreenUpdating = False
Sheets("Final").Select
Set rFinalA = Range("A10", Range("A" & Rows.Count).End(xlUp))
With Sheets("Imported Data")
Set rImportA = .Range("A10", .Range("A" & Rows.Count).End(xlUp))
End With
DestCol = Cells(10, Columns.Count).End(xlToLeft).Offset(, 1).Column
For Each i In rImportA
If Not rFinalA.Find(What:=i.Value, Lookat:=xlWhole) Is Nothing
Then
DestRow = rFinalA.Find(What:=i.Value, Lookat:=xlWhole).Row
i.Offset(, 1).Resize(, 8).Copy
Cells(DestRow, DestCol).PasteSpecial xlPasteValues
Else
MsgBox "The company " & i.Value & " could not be found in
Column A of the Final sheet." & Chr(13) & _
"The data for that company will not be
copied/pasted." & Chr(13) & _
"This program will continue with the rest of the
data.", 16, "Missing Company"
End If
Next i
With Sheets("Imported Data")
If Not IsEmpty(.Range("A10").Value) Then _
.Range("A10", .Range("A" & Rows.Count).End(xlUp).Offset(,
8)).ClearContents
End With
Application.ScreenUpdating = True
End Sub