Need Some Finesse Combining Sheets

DJAnthonyMark

New Member
Joined
Sep 30, 2011
Messages
8
So I got assigned the project of the year for the company. I need to combine about 15 years of inventory into a searchable database so that I can import it into our new software.

I managed to normalize the data from its multiple "index cards" to lists on worksheets. Now I need to combine those worksheets into one and than all of them into one complete list.

Here is the the Macro I currently use to combine sheets. I've used this before to combine multiple inventories for importing. It combines fine and then I manually cleanup the data little to make it look good. The problem is, I don't know how to make the Macro independent of each sheet name, this way it runs on all sheets, regardless of the name. Also, the data needs to be combined using a paste values, because of the way the functions were setup, i don't want the formulas to carry over.

Can someone help me? Where am I going wrong?
==========================

Sub Collate_Sheets()

'Put Data in NEW Combined Inventory
Sheets.Add After:=Sheets(Sheets.Count)
Dim wks As Worksheet
Set wks = Sheets(Sheets.Count)
wks.Name = "CombinedInventory"

'Grabbing CDA911.250DROPSPBXXT
With Sheets("CDA911.250DROPSPBXXT")
Dim lastrow As Long
lastrow = .Range("B" & .Rows.Count).End(xlUp).Row
.Range("A1:ET" & lastrow).Copy wks.Range("A" & wks.Rows.Count).End(xlUp)
End With

'Grabbing CDA911.375DROPSPBXXT
With Sheets("CDA911.375DROPSPBXXT")
lastrow = .Range("B" & .Rows.Count).End(xlUp).Row
.Range("A2:ET" & lastrow).Copy wks.Range("A" & wks.Rows.Count).End(xlUp).Offset(1)
End With

'CDA911.500DROPSPBXXT
With Sheets("CDA911.500DROPSPBXXT")
lastrow = .Range("B" & .Rows.Count).End(xlUp).Row
.Range("A2:ET" & lastrow).Copy wks.Range("A" & wks.Rows.Count).End(xlUp).Offset(1)
End With


'CDA911.625THICKDROPPBXXT
With Sheets("CDA911.625THICKDROPPBXXT")
lastrow = .Range("B" & .Rows.Count).End(xlUp).Row
.Range("A2:ET" & lastrow).Copy wks.Range("A" & wks.Rows.Count).End(xlUp).Offset(1)
End With


'CDA911.750DROPSPBXXT
With Sheets("CDA911.750DROPSPBXXT")
lastrow = .Range("B" & .Rows.Count).End(xlUp).Row
.Range("A2:ET" & lastrow).Copy wks.Range("A" & wks.Rows.Count).End(xlUp).Offset(1)
End With


'CDA911.875DROPSPBXXT
With Sheets("CDA911.875DROPSPBXXT")
lastrow = .Range("B" & .Rows.Count).End(xlUp).Row
.Range("A2:ET" & lastrow).Copy wks.Range("A" & wks.Rows.Count).End(xlUp).Offset(1)
End With

End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,216,218
Messages
6,129,571
Members
449,518
Latest member
srooney

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top