Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

tranform row to column...across 500 excel workbooks

Posted on 2015-02-17
21
Medium Priority
?
96 Views
Last Modified: 2016-02-11
i have a folder of 500 workbooks

i have data in a1
then across row 2 --- of varying length

i need to append all this data into one column

i would like to do it across every workbook automaticaly
0
Comment
Question by:finnstone
  • 12
  • 9
21 Comments
 
LVL 46

Expert Comment

by:aikimark
ID: 40613990
Please post a workbook with representative data.
Where do you need to place this transformed data?
0
 

Author Comment

by:finnstone
ID: 40614020
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40614055
Your workbook needs to show what the transformed data should look like.  Please post your files in this thread.
animatedtabs.csv
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:finnstone
ID: 40614074
I need All the data in column A that's it
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40614231
0
 

Author Comment

by:finnstone
ID: 40614246
yes
0
 
LVL 46

Accepted Solution

by:
aikimark earned 2000 total points
ID: 40614581
Here is a VBA routine to do this for all the csv files in a directory.  Change the cPath string literal to point to the directory with your 500 csv files.
Sub Q_28618360()
    Dim strFilename As String
    Dim wkb As Workbook
    Dim wks As Worksheet
    Const cPath As String = "C:\Users\AikiMark\Downloads\Q_28618360\"
    strFilename = Dir(cPath & "*.csv")
    Do Until Len(strFilename) = 0
        Set wkb = Workbooks.Open(cPath & strFilename)
        Set wks = wkb.Sheets(1)
        wks.Range(wks.Range("A2"), wks.Range("A2").Offset(ActiveSheet.Range("A2").End(xlToRight).Column - 1, 0)).Value = _
            WorksheetFunction.Transpose(wks.Range(wks.Range("A2"), wks.Range("A2").End(xlToRight)).Value)
        wks.Range(wks.Range("B2"), wks.Range("B2").End(xlToRight)).ClearContents
        wkb.Close True
        strFilename = Dir
    Loop

End Sub

Open in new window

0
 

Author Comment

by:finnstone
ID: 40614740
strFilename  is equaling "" everytime ...
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40614811
What does your code look like?
Where are your CSV files?
0
 

Author Comment

by:finnstone
ID: 40614830
i used your code exactly
put it in a module
0
 

Author Comment

by:finnstone
ID: 40614832
yes i modified path to correct path
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40614881
Are you invoking the routine in the module?
0
 

Author Comment

by:finnstone
ID: 40614883
no. how do i do that?
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40614938
just invoke it by name somewhere in the file, usually at the top of the file.

Also, make sure your path ends with a back slash, like mine did.
0
 

Author Comment

by:finnstone
ID: 40614960
beautiful got it :)
0
 

Author Comment

by:finnstone
ID: 40614961
thanks this is awesome!
0
 

Author Closing Comment

by:finnstone
ID: 40614965
great!!
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40615034
Is this a one-time transform?
0
 

Author Comment

by:finnstone
ID: 40615041
yeah already done. posting a new problem though :)
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40615062
post a link to that new question in this thread
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question