View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Arvi Laanemets Arvi Laanemets is offline
external usenet poster
 
Posts: 510
Default Query - Data Layout

Hi

One possible way:
On new sheet, create a table
User Profile

A2:B2 in this table enter formulas (I assume original data are on Sheet1,
and that there can be up to 7 different profiles per user)
=IF(OFFSET(Sheet1!$A$1,INT((ROW()-2)/7),)="","",OFFSET(Sheet1!$A$1,INT((ROW()-2)/7),))
=IF(OFFSET(Sheet1!$A$1,INT((ROW()-2)/7),MOD(ROW()-2,7)+1)="","",OFFSET(Sheet1!$A$1,INT((ROW()-2)/7),MOD(ROW()-2,7)+1))
(When the max. number of profiles per user is different from 7, replace the
number 7 in formula with your own value)
Copy formulas down for so many rows as you need - a table is created.

Now you have to discard rows without profile value. There are several ways
for it - a couple of them below:
1. Using Paste Special, convert formulas to values. Using Autofilter, copy
all rows where Profile is not empty, and paste copied cells into new sheet.
2. Define the created table as a named range. Use this range as a source for
an ODBC query, to retrieve all rows where Profile is not empty, into a new
table on another sheet.


--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )



wrote in message
oups.com...
I have a series of data as set out below which I need to amend in to a
flat file. The requirement is for each User ID record to have a line
for every profile that the user has.

Currently my excel spreadsheet has every user ID going across in
columns per user (see below). I need this to appear as per example 2.

Column A Column B Column C Column D Column E
User1 Profile1 Profile2 Profile3
User2 Profile2 Profile4
User3 Profile4 Profile5 Profile6 Profile7


Should appear like (Example 2):
Column A Column B
User1 Profile1
User1 Profile2
User1 Profile3
User2 Profile2
User2 Profile4
User3 Profile4
User3 Profile5
User3 Profile6
User3 Profile7

Please can you assist with this - I'm not sure how this is done,
however assuming this could be something that could be done in VBA?

Many Thanks, Al.