Automate Transpose One Column, Copy Another Column

Please see the attached file.  On Sheet 1, Column A contains trend codes.  Columns B potentially all the way through Column X contain codes that are to be mapped to Column A.

The challenge I have is to take Columns B through X, copy and transpose them onto Sheet 2 so that they are all in one column.  Then I need to copy Column A and paste it in the second column on Sheet 2 in each cell next to its corresponding code from Sheet 1.

I could do this all manually, but I am hoping I can automate it with code and there are 1118 rows which could take many hours.  I am very familiar with vba for Access, but I have never done any coding for Excel.
Trend-Codes.xlsx
SDKCompanyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nutschCommented:
Hi,

Here's code that should do just that (at least, if I understood what you needed).

Sub yeaaah()
Dim rgCell As Range, shtOrg As Worksheet, shtDest As Worksheet
Dim lRowDest As Long
'turn off updates to speed up code execution
With Application
    .ScreenUpdating = False
    .EnableEvents = False
    .Calculation = xlCalculationManual
    .DisplayAlerts = False
End With

Set shtOrg = ActiveSheet
Set shtDest = Sheets.Add

For Each rgCell In shtOrg.Cells(2, 2).Resize(shtOrg.UsedRange.Rows.Count - 1, shtOrg.UsedRange.Columns.Count - 1).SpecialCells(xlCellTypeConstants)
    shtDest.Cells(lRowDest + 1, 1) = rgCell
    shtDest.Cells(lRowDest + 1, 2) = shtOrg.Cells(rgCell.Row, 1)
    lRowDest = lRowDest + 1
Next rgCell

With Application
    .ScreenUpdating = True
    .EnableEvents = True
    .Calculation = xlCalculationAutomatic
    .DisplayAlerts = True
End With



End Sub

Open in new window


Thomas
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Harry LeeCommented:
SDKCompany,

Can you post the ending result for the sample file you have uploaded?

Have no idea what are you trying to do exactly.
0
SDKCompanyAuthor Commented:
I have uploaded the Excel file with a tab that has an example of what I am looking to get for the final product.  I have used the data from the first 8 rows of Sheet1 for the example.

Thomas,

I have not had a chance to try your code yet, but I will post the results as soon as I can.

Thanks,

Kyle
Trend-Codes-w-Example.xlsx
0
SDKCompanyAuthor Commented:
Thomas,

Your code works great.  I need to do a little more verification, but it appears that it does exactly what I need.  Thank you!
0
SDKCompanyAuthor Commented:
Worked perfectly!  Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.