Macro/VBA Help - splitting and adding rows (or Access instead?)

RegistrationMom

New Member
Joined
Jul 12, 2015
Messages
8
So I'm collecting web form entries in csv file.

Current row headings - Parent, NoOfChildren, Child1, Child1Details, Child2, Child2Details, Child3, Child3Details

I would like to get a more 'vertical' listing, ie -

Parent1, Child1, Child1Details
Parent1, Child2, Child2Details
Parent1, Child3, Child3Details
Parent2, Child1, Child1Details
Parent2, Child2, Child2Details
Parent3, Child1, Child1Details

I also putz a bit in Access but am unable to contrive a query that does this - so I figure if I can get the Excel sheet list in line, I'm good to go. . . I'll cross-post this in the Excel Forum.

This is bit more complicated than just 'transpose!'

Using MS Office 2007

Thanks so much!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Don't know how your data is arranged in Access table that you've been 'putzin' with, but I'm thinking a cross-tab query could be a solution. But not if a csv file is your datasource. If that's the case, you will need a custom function that uses the split/join functions in Access. You can retrieve results in a query if you add your function call for each value that you want to retrieve, passing (n) as the argument. Obviously, this approach is not very dynamic if you want to make changes to the size of your array or change field names afterwards.
 
Upvote 0
Cross-posted: http://www.mrexcel.com/forum/excel-...elp-splitting-adding-rows-access-instead.html

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule #10 here: http://www.mrexcel.com/forum/board-announcements/99490-forum-rules.html). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Thanks Micron.

I don't really have anything set-up in Access. I download my csv file - open in Excel - the import to Access, in hopes of being able to set-up an simple query. I'll check a crosstab - but you lost me with passing arguments and my array size!

Appreciate your time!
 
Upvote 0
if your array (cs values) is something like (1,2,3,4,5) the split function will return the nth value if you tell it to get n. You create a custom function something like
function getAryValue(n)
'in here you define the variables, get the array string via recordset for example
'and use the split function to get the nth value, based on what the separator is (,)
'and make getAryValue = 'the nth character' disregarding ,'s
end function
In a query design view, you put MyFieldName:getAryValue(1) in a column, then MyFieldName2:getAryValue(2) in the next column and so on.

you cannot separate the csv values with an ordinary query. Your other option is to use Excel's text to columns feature to split the values into columns and use that either in Excel or Access.
 
Upvote 0

Forum statistics

Threads
1,221,849
Messages
6,162,425
Members
451,765
Latest member
craigvan888

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