Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default transposing repeating data records in excel

I am trying to transpose repeating records in excel. My data is exported
from a Lotus notes database. I have selected to export and use a "G" to
separate each record. I need to align similar classes of data in similar
columns so I can map fields when importing the records into Outlook. I am
really only interested in the following data from each record [ streetname,
cityname, statecode, postcode, comname]. Of course when I exported the data
from Lotus notes, I got a template with lots of generic data fields in column
A and the unique data in column B. Here is a sample of the data.

G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode E01
PreLocationCode E01
PreLocationName
Administrator [Manager]
Readers [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode E01
LocationName
StreetName 600 Thomas Drive
POBox
CityName New York
StateCode NY
StateName New York
PostCode 10999
CountryCode USA
CountryName United States
Tel
Fax
CurrencyCode USD
CurrencyName US Dollar
LanguageCode ENG
LanguageName English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors ,,
ComName Humphry, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate xxxx
UpdateName xxxx
ComType 1
OldComCode axxxx
PreComCode
ComCode axxxx
$UpdatedBy xxxx



G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode E01
PreLocationCode E01
PreLocationName
Administrator [Manager]
Readers [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode E01
LocationName
StreetName One Best Rd
POBox
CityName Lisbon
StateCode OH
StateName Ohio
PostCode 19203
CountryCode USA
CountryName United States
Tel 301-999-3911
Fax
CurrencyCode USD
CurrencyName US Dollar
LanguageCode ENG
LanguageName English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors ,,
ComName Lustor, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate
UpdateName xxxxx
ComType 1
OldComCode xxxxx
PreComCode
ComCode xxxxx
$UpdatedBy xxxxx


Can anyone help me?


--
Zigman
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default transposing repeating data records in excel

Hi

With the imported data in Sheet 1, this macro will generate a list in sheet2
with the desired data:

Sub TransposeData()
Dim DestSh As Worksheet
Dim TargetSh As Worksheet

Set TargetSh = Sheets("Sheet1")
Set DestSh = Sheets("Sheet2")
DestRow = 2 ' Headings in row 1

TargetSh.Activate

lastrow = Range("A" & Rows.Count).End(xlUp).Row
Set f = Columns("A").Find(what:="G", After:=Range("A" & lastrow),
lookat:=xlWhole, MatchCase:=True)
Debug.Print f.Row
Do
DestSh.Cells(DestRow, 1) = Cells(f.Row + 21, 2).Value
DestSh.Cells(DestRow, 2) = Cells(f.Row + 23, 2).Value
DestSh.Cells(DestRow, 3) = Cells(f.Row + 24, 2).Value
DestSh.Cells(DestRow, 4) = Cells(f.Row + 26, 2).Value
DestSh.Cells(DestRow, 5) = Cells(f.Row + 47, 2).Value
DestRow = DestRow + 1
fRow = f.Row
Set f = Columns("A").Find(what:="G", After:=Range("A" & f.Row), _
lookat:=xlWhole, MatchCase:=True)
Loop Until f.Row = 1
End Sub

Regards,
Per

"zigman" skrev i meddelelsen
...
I am trying to transpose repeating records in excel. My data is exported
from a Lotus notes database. I have selected to export and use a "G" to
separate each record. I need to align similar classes of data in similar
columns so I can map fields when importing the records into Outlook. I
am
really only interested in the following data from each record [
streetname,
cityname, statecode, postcode, comname]. Of course when I exported the
data
from Lotus notes, I got a template with lots of generic data fields in
column
A and the unique data in column B. Here is a sample of the data.

G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode E01
PreLocationCode E01
PreLocationName
Administrator [Manager]
Readers [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode E01
LocationName
StreetName 600 Thomas Drive
POBox
CityName New York
StateCode NY
StateName New York
PostCode 10999
CountryCode USA
CountryName United States
Tel
Fax
CurrencyCode USD
CurrencyName US Dollar
LanguageCode ENG
LanguageName English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors ,,
ComName Humphry, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate xxxx
UpdateName xxxx
ComType 1
OldComCode axxxx
PreComCode
ComCode axxxx
$UpdatedBy xxxx



G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode E01
PreLocationCode E01
PreLocationName
Administrator [Manager]
Readers [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode E01
LocationName
StreetName One Best Rd
POBox
CityName Lisbon
StateCode OH
StateName Ohio
PostCode 19203
CountryCode USA
CountryName United States
Tel 301-999-3911
Fax
CurrencyCode USD
CurrencyName US Dollar
LanguageCode ENG
LanguageName English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors ,,
ComName Lustor, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate
UpdateName xxxxx
ComType 1
OldComCode xxxxx
PreComCode
ComCode xxxxx
$UpdatedBy xxxxx


Can anyone help me?


--
Zigman


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default transposing repeating data records in excel

Hello Per Jessen. First, I want to thank you for taking time to answer my
question.
I tried to run the program in the excel vb editor and there is a syntax error
associated with the following line of the program

Set f = Columns("A").Find(what:="G", After:=Range("A" & lastrow),
lookat:=xlWhole, MatchCase:=True)

Do you know what the problem could be?
--
Zigman


"Per Jessen" wrote:

Hi

With the imported data in Sheet 1, this macro will generate a list in sheet2
with the desired data:

Sub TransposeData()
Dim DestSh As Worksheet
Dim TargetSh As Worksheet

Set TargetSh = Sheets("Sheet1")
Set DestSh = Sheets("Sheet2")
DestRow = 2 ' Headings in row 1

TargetSh.Activate

lastrow = Range("A" & Rows.Count).End(xlUp).Row
Set f = Columns("A").Find(what:="G", After:=Range("A" & lastrow),
lookat:=xlWhole, MatchCase:=True)
Debug.Print f.Row
Do
DestSh.Cells(DestRow, 1) = Cells(f.Row + 21, 2).Value
DestSh.Cells(DestRow, 2) = Cells(f.Row + 23, 2).Value
DestSh.Cells(DestRow, 3) = Cells(f.Row + 24, 2).Value
DestSh.Cells(DestRow, 4) = Cells(f.Row + 26, 2).Value
DestSh.Cells(DestRow, 5) = Cells(f.Row + 47, 2).Value
DestRow = DestRow + 1
fRow = f.Row
Set f = Columns("A").Find(what:="G", After:=Range("A" & f.Row), _
lookat:=xlWhole, MatchCase:=True)
Loop Until f.Row = 1
End Sub

Regards,
Per

"zigman" skrev i meddelelsen
...
I am trying to transpose repeating records in excel. My data is exported
from a Lotus notes database. I have selected to export and use a "G" to
separate each record. I need to align similar classes of data in similar
columns so I can map fields when importing the records into Outlook. I
am
really only interested in the following data from each record [
streetname,
cityname, statecode, postcode, comname]. Of course when I exported the
data
from Lotus notes, I got a template with lots of generic data fields in
column
A and the unique data in column B. Here is a sample of the data.

G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode E01
PreLocationCode E01
PreLocationName
Administrator [Manager]
Readers [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode E01
LocationName
StreetName 600 Thomas Drive
POBox
CityName New York
StateCode NY
StateName New York
PostCode 10999
CountryCode USA
CountryName United States
Tel
Fax
CurrencyCode USD
CurrencyName US Dollar
LanguageCode ENG
LanguageName English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors ,,
ComName Humphry, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate xxxx
UpdateName xxxx
ComType 1
OldComCode axxxx
PreComCode
ComCode axxxx
$UpdatedBy xxxx



G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode E01
PreLocationCode E01
PreLocationName
Administrator [Manager]
Readers [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode E01
LocationName
StreetName One Best Rd
POBox
CityName Lisbon
StateCode OH
StateName Ohio
PostCode 19203
CountryCode USA
CountryName United States
Tel 301-999-3911
Fax
CurrencyCode USD
CurrencyName US Dollar
LanguageCode ENG
LanguageName English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors ,,
ComName Lustor, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate
UpdateName xxxxx
ComType 1
OldComCode xxxxx
PreComCode
ComCode xxxxx
$UpdatedBy xxxxx


Can anyone help me?


--
Zigman



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default transposing repeating data records in excel

Hello Zigman

The problem is word wrap in your news editor.

The code mentioned shall be entered as one line or with a " _ " as
line seperator as I did later in the code.


---
Per

On 7 Jan., 03:34, zigman wrote:
Hello Per Jessen. *First, I want to thank you for taking time to answer my
question. * *
I tried to run the program in the excel vb editor and there is a syntax error
associated with the following line of the program

Set f = Columns("A").Find(what:="G", After:=Range("A" & lastrow),
lookat:=xlWhole, MatchCase:=True)

Do you know what the problem could be?
--
Zigman



"Per Jessen" wrote:
Hi


With the imported data in Sheet 1, this macro will generate a list in sheet2
with the desired data:


Sub TransposeData()
Dim DestSh As Worksheet
Dim TargetSh As Worksheet


Set TargetSh = Sheets("Sheet1")
Set DestSh = Sheets("Sheet2")
DestRow = 2 ' Headings in row 1


TargetSh.Activate


lastrow = Range("A" & Rows.Count).End(xlUp).Row
Set f = Columns("A").Find(what:="G", After:=Range("A" & lastrow),
lookat:=xlWhole, MatchCase:=True)
Debug.Print f.Row
Do
* * DestSh.Cells(DestRow, 1) = Cells(f.Row + 21, 2).Value
* * DestSh.Cells(DestRow, 2) = Cells(f.Row + 23, 2).Value
* * DestSh.Cells(DestRow, 3) = Cells(f.Row + 24, 2).Value
* * DestSh.Cells(DestRow, 4) = Cells(f.Row + 26, 2).Value
* * DestSh.Cells(DestRow, 5) = Cells(f.Row + 47, 2).Value
* * DestRow = DestRow + 1
* * fRow = f.Row
* * Set f = Columns("A").Find(what:="G", After:=Range("A" & f..Row), *_
* * * * lookat:=xlWhole, MatchCase:=True)
Loop Until f.Row = 1
End Sub


Regards,
Per


"zigman" skrev i meddelelsen
...
I am trying to transpose repeating records in excel. *My data is exported
from a Lotus notes database. *I have selected to export and use a "G" to
separate each record. *I need to align similar classes of data in similar
columns so I can map fields when importing the records into Outlook. * *I
am
really only interested in the following data from each record [
streetname,
cityname, statecode, postcode, comname]. *Of course when I exported the
data
from Lotus notes, I got a template with lots of generic data fields in
column
A and the unique data in column B. *Here is a sample of the data.


G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode * E01
PreLocationCode * E01
PreLocationName
Administrator * [Manager]
Readers * [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode * E01
LocationName
StreetName * 600 Thomas Drive
POBox
CityName * New York
StateCode NY
StateName New York
PostCode 10999
CountryCode * USA
CountryName * United States
Tel
Fax
CurrencyCode * USD
CurrencyName * US Dollar
LanguageCode * ENG
LanguageName * English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors * ,,
ComName Humphry, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate xxxx
UpdateName xxxx
ComType 1
OldComCode axxxx
PreComCode
ComCode axxxx
$UpdatedBy xxxx


G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode * E01
PreLocationCode * E01
PreLocationName
Administrator * [Manager]
Readers * [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode * E01
LocationName
StreetName * One Best Rd
POBox
CityName Lisbon
StateCode OH
StateName Ohio
PostCode 19203
CountryCode * USA
CountryName * United States
Tel * 301-999-3911
Fax
CurrencyCode * USD
CurrencyName * US Dollar
LanguageCode * ENG
LanguageName * English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors * ,,
ComName Lustor, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate
UpdateName xxxxx
ComType 1
OldComCode xxxxx
PreComCode
ComCode xxxxx
$UpdatedBy xxxxx


Can anyone help me?


--
Zigman- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default transposing repeating data records in excel

Hi Per,
OH WOW! It works beautifully! Thank you so much!

I have similar export data type with slightly different info. Since the
data that I need to pull from this alternate format has different row
locations on the spreadsheet, I tried to modify the macro code to adjust for
this format by changing the following line of the macro (to pull the
telephone number data)

'DestSh.Cells(DestRow, 1) = Cells(f.Row + 11, 2).Value

I changed 21 to 11 because it was 11 rows below the 'G'. It created a bug.
It probably isnt that simple anyway, because some of the records have
€˜Precomcode in the row directly below the €˜G and some dont. This count
method that I was thinking of changing would vary between records. So below
is a sample of this repeating customer data. I am interested in the
following fields [FirstName, LastName, Post, Tel, Fax, Email, ComName].

$ConflictAction 1
OldLocationCode E01
LocationCode E01
LocationName
DeptName
Sex 1
Title Mr.
FirstName Tony
LastName Thomason
Post Shipping supervisor
Tel 554-593-5451
Fax 994-592-5460
EMail

PersonalTel
HomeAddress
HomeTel
Birthday
Hobby
Children
Memo
CreateDate
CreateName
DeptCode
ComName Larson Construction
FullName Tony Thomason
OldComCode
PreComCode
ComCode
$UpdatedBy

G
PreComCode
$ConflictAction 1
OldComCode A0705
OldLocationCode E01
LocationCode E01
LocationName
DeptName
Sex 1
Title Mr.
FirstName Paul
LastName Thompson
Post Purchasing Mgr
Tel 984-854-7700
Fax 498-592-5460
EMail


PersonalTel
HomeAddress
HomeTel
Birthday
Hobby
Children
Memo
CreateDate
CreateName
ComCode
DeptCode
ComName Larson Construction
FullName Paul Thompson
$UpdatedBy
$Revisions 43 23 PM

G
$ConflictAction 1
OldComCode A0705
OldLocationCode E01
LocationCode E01
LocationName
DeptName
Sex 1
Title Mr.
FirstName Sally
LastName Valley
Post Machine Designer
Tel 444-548-7700
Fax 477-592-5433
EMail


PersonalTel
HomeAddress
HomeTel
Birthday
Hobby
Children
Memo
CreateDate 09/22/2008 01 44 42 PM
CreateName
ComCode
DeptCode
ComName Larson Construction
FullName Sally Valley
$UpdatedBy
$Revisions 09/22/2008 01 45 13 PM

G
$ConflictAction 1
OldLocationCode E01
LocationCode E01
LocationName
DeptName
Sex 2
Title Ms.
FirstName Janice
LastName Miller
Post Purchasing
Tel 477-843-9428
Fax
EMail


PersonalTel
HomeAddress
HomeTel
Birthday
Hobby
Children
Memo
CreateDate 23 59 PM
CreateName
DeptCode 1
ComName Standish Company
FullName
OldComCode
PreComCode
ComCode
$UpdatedBy

G


--
Zigman


"Per Jessen" wrote:

Hello Zigman

The problem is word wrap in your news editor.

The code mentioned shall be entered as one line or with a " _ " as
line seperator as I did later in the code.


---
Per

On 7 Jan., 03:34, zigman wrote:
Hello Per Jessen. First, I want to thank you for taking time to answer my
question.
I tried to run the program in the excel vb editor and there is a syntax error
associated with the following line of the program

Set f = Columns("A").Find(what:="G", After:=Range("A" & lastrow),
lookat:=xlWhole, MatchCase:=True)

Do you know what the problem could be?
--
Zigman



"Per Jessen" wrote:
Hi


With the imported data in Sheet 1, this macro will generate a list in sheet2
with the desired data:


Sub TransposeData()
Dim DestSh As Worksheet
Dim TargetSh As Worksheet


Set TargetSh = Sheets("Sheet1")
Set DestSh = Sheets("Sheet2")
DestRow = 2 ' Headings in row 1


TargetSh.Activate


lastrow = Range("A" & Rows.Count).End(xlUp).Row
Set f = Columns("A").Find(what:="G", After:=Range("A" & lastrow),
lookat:=xlWhole, MatchCase:=True)
Debug.Print f.Row
Do
DestSh.Cells(DestRow, 1) = Cells(f.Row + 21, 2).Value
DestSh.Cells(DestRow, 2) = Cells(f.Row + 23, 2).Value
DestSh.Cells(DestRow, 3) = Cells(f.Row + 24, 2).Value
DestSh.Cells(DestRow, 4) = Cells(f.Row + 26, 2).Value
DestSh.Cells(DestRow, 5) = Cells(f.Row + 47, 2).Value
DestRow = DestRow + 1
fRow = f.Row
Set f = Columns("A").Find(what:="G", After:=Range("A" & f..Row), _
lookat:=xlWhole, MatchCase:=True)
Loop Until f.Row = 1
End Sub


Regards,
Per


"zigman" skrev i meddelelsen
...
I am trying to transpose repeating records in excel. My data is exported
from a Lotus notes database. I have selected to export and use a "G" to
separate each record. I need to align similar classes of data in similar
columns so I can map fields when importing the records into Outlook. I
am
really only interested in the following data from each record [
streetname,
cityname, statecode, postcode, comname]. Of course when I exported the
data
from Lotus notes, I got a template with lots of generic data fields in
column
A and the unique data in column B. Here is a sample of the data.


G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode E01
PreLocationCode E01
PreLocationName
Administrator [Manager]
Readers [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode E01
LocationName
StreetName 600 Thomas Drive
POBox
CityName New York
StateCode NY
StateName New York
PostCode 10999
CountryCode USA
CountryName United States
Tel
Fax
CurrencyCode USD
CurrencyName US Dollar
LanguageCode ENG
LanguageName English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors ,,
ComName Humphry, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate xxxx
UpdateName xxxx
ComType 1
OldComCode axxxx
PreComCode
ComCode axxxx
$UpdatedBy xxxx


G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode E01
PreLocationCode E01
PreLocationName
Administrator [Manager]
Readers [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode E01
LocationName
StreetName One Best Rd
POBox
CityName Lisbon
StateCode OH
StateName Ohio
PostCode 19203
CountryCode USA
CountryName United States
Tel 301-999-3911
Fax
CurrencyCode USD
CurrencyName US Dollar
LanguageCode ENG
LanguageName English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors ,,
ComName Lustor, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate
UpdateName xxxxx
ComType 1
OldComCode xxxxx
PreComCode
ComCode xxxxx
$UpdatedBy xxxxx


Can anyone help me?


--
Zigman- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default transposing repeating data records in excel

Hi Zigman,

Thanks for your reply.

The change you made was right, it's very simple :-) I don't see any bug,
just a single quote sign starting the line indicating that it's a comment.

This solution doesn't care about differences in data structure, and more
fields can eaisily be added if needed:

Option Base 1
Sub TransposeData()
Dim DestSh As Worksheet
Dim TargetSh As Worksheet
Dim Posts

Posts = Array("FirstName", "LastName", "Post", "Tel", "Fax", "Email",
"ComName")

Set TargetSh = Sheets("Sheet1")
Set DestSh = Sheets("Sheet2")
DestRow = 2 ' Headings in row 1

TargetSh.Activate

lastrow = Range("A" & Rows.Count).End(xlUp).Row
Set f = Columns("A").Find(What:="G", after:=Range("A" & lastrow),
lookat:=xlWhole, MatchCase:=True)
Do
For x = LBound(Posts) To UBound(Posts)
Set p = Columns("A").Find(What:=Posts(x), after:=Range("A" & f.Row))
DestSh.Cells(DestRow, x) = Cells(p.Row, 2).Value
Next
DestRow = DestRow + 1
Set f = Columns("A").Find(What:="G", after:=Range("A" & f.Row), _
lookat:=xlWhole, MatchCase:=True)
Loop Until f.Row = 1
End Sub

Regards,
Per

"zigman" skrev i meddelelsen
...
Hi Per,
OH WOW! It works beautifully! Thank you so much!

I have similar export data type with slightly different info. Since the
data that I need to pull from this alternate format has different row
locations on the spreadsheet, I tried to modify the macro code to adjust
for
this format by changing the following line of the macro (to pull the
telephone number data)

'DestSh.Cells(DestRow, 1) = Cells(f.Row + 11, 2).Value

I changed 21 to 11 because it was 11 rows below the 'G'. It created a
bug.
It probably isnt that simple anyway, because some of the records have
€˜Precomcode in the row directly below the €˜G and some dont. This count
method that I was thinking of changing would vary between records. So
below
is a sample of this repeating customer data. I am interested in the
following fields [FirstName, LastName, Post, Tel, Fax, Email, ComName].

$ConflictAction 1
OldLocationCode E01
LocationCode E01
LocationName
DeptName
Sex 1
Title Mr.
FirstName Tony
LastName Thomason
Post Shipping supervisor
Tel 554-593-5451
Fax 994-592-5460
EMail

PersonalTel
HomeAddress
HomeTel
Birthday
Hobby
Children
Memo
CreateDate
CreateName
DeptCode
ComName Larson Construction
FullName Tony Thomason
OldComCode
PreComCode
ComCode
$UpdatedBy

G
PreComCode
$ConflictAction 1
OldComCode A0705
OldLocationCode E01
LocationCode E01
LocationName
DeptName
Sex 1
Title Mr.
FirstName Paul
LastName Thompson
Post Purchasing Mgr
Tel 984-854-7700
Fax 498-592-5460
EMail


PersonalTel
HomeAddress
HomeTel
Birthday
Hobby
Children
Memo
CreateDate
CreateName
ComCode
DeptCode
ComName Larson Construction
FullName Paul Thompson
$UpdatedBy
$Revisions 43 23 PM

G
$ConflictAction 1
OldComCode A0705
OldLocationCode E01
LocationCode E01
LocationName
DeptName
Sex 1
Title Mr.
FirstName Sally
LastName Valley
Post Machine Designer
Tel 444-548-7700
Fax 477-592-5433
EMail


PersonalTel
HomeAddress
HomeTel
Birthday
Hobby
Children
Memo
CreateDate 09/22/2008 01 44 42 PM
CreateName
ComCode
DeptCode
ComName Larson Construction
FullName Sally Valley
$UpdatedBy
$Revisions 09/22/2008 01 45 13 PM

G
$ConflictAction 1
OldLocationCode E01
LocationCode E01
LocationName
DeptName
Sex 2
Title Ms.
FirstName Janice
LastName Miller
Post Purchasing
Tel 477-843-9428
Fax
EMail


PersonalTel
HomeAddress
HomeTel
Birthday
Hobby
Children
Memo
CreateDate 23 59 PM
CreateName
DeptCode 1
ComName Standish Company
FullName
OldComCode
PreComCode
ComCode
$UpdatedBy

G


--
Zigman


"Per Jessen" wrote:

Hello Zigman

The problem is word wrap in your news editor.

The code mentioned shall be entered as one line or with a " _ " as
line seperator as I did later in the code.


---
Per

On 7 Jan., 03:34, zigman wrote:
Hello Per Jessen. First, I want to thank you for taking time to answer
my
question.
I tried to run the program in the excel vb editor and there is a syntax
error
associated with the following line of the program

Set f = Columns("A").Find(what:="G", After:=Range("A" & lastrow),
lookat:=xlWhole, MatchCase:=True)

Do you know what the problem could be?
--
Zigman



"Per Jessen" wrote:
Hi

With the imported data in Sheet 1, this macro will generate a list in
sheet2
with the desired data:

Sub TransposeData()
Dim DestSh As Worksheet
Dim TargetSh As Worksheet

Set TargetSh = Sheets("Sheet1")
Set DestSh = Sheets("Sheet2")
DestRow = 2 ' Headings in row 1

TargetSh.Activate

lastrow = Range("A" & Rows.Count).End(xlUp).Row
Set f = Columns("A").Find(what:="G", After:=Range("A" & lastrow),
lookat:=xlWhole, MatchCase:=True)
Debug.Print f.Row
Do
DestSh.Cells(DestRow, 1) = Cells(f.Row + 21, 2).Value
DestSh.Cells(DestRow, 2) = Cells(f.Row + 23, 2).Value
DestSh.Cells(DestRow, 3) = Cells(f.Row + 24, 2).Value
DestSh.Cells(DestRow, 4) = Cells(f.Row + 26, 2).Value
DestSh.Cells(DestRow, 5) = Cells(f.Row + 47, 2).Value
DestRow = DestRow + 1
fRow = f.Row
Set f = Columns("A").Find(what:="G", After:=Range("A" & f..Row),
_
lookat:=xlWhole, MatchCase:=True)
Loop Until f.Row = 1
End Sub

Regards,
Per

"zigman" skrev i meddelelsen
...
I am trying to transpose repeating records in excel. My data is
exported
from a Lotus notes database. I have selected to export and use a
"G" to
separate each record. I need to align similar classes of data in
similar
columns so I can map fields when importing the records into
Outlook. I
am
really only interested in the following data from each record [
streetname,
cityname, statecode, postcode, comname]. Of course when I exported
the
data
from Lotus notes, I got a template with lots of generic data fields
in
column
A and the unique data in column B. Here is a sample of the data.

G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode E01
PreLocationCode E01
PreLocationName
Administrator [Manager]
Readers [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode E01
LocationName
StreetName 600 Thomas Drive
POBox
CityName New York
StateCode NY
StateName New York
PostCode 10999
CountryCode USA
CountryName United States
Tel
Fax
CurrencyCode USD
CurrencyName US Dollar
LanguageCode ENG
LanguageName English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors ,,
ComName Humphry, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate xxxx
UpdateName xxxx
ComType 1
OldComCode axxxx
PreComCode
ComCode axxxx
$UpdatedBy xxxx

G
ADRNO
ADR
COMPANYTYPE
ENDFLG 1
$ConflictAction 1
Startup 1
OldLocationCode E01
PreLocationCode E01
PreLocationName
Administrator [Manager]
Readers [Manager]
SalesPersonNotesID
InsidePersonNotesID
AreaManagerNotesID
UserList
CLDCode
SelectList
ComAdditionalName
LocationCode E01
LocationName
StreetName One Best Rd
POBox
CityName Lisbon
StateCode OH
StateName Ohio
PostCode 19203
CountryCode USA
CountryName United States
Tel 301-999-3911
Fax
CurrencyCode USD
CurrencyName US Dollar
LanguageCode ENG
LanguageName English
PayMethodCode
PayMethodName
PayTermCode
PayTermName
KeyPerson
SalesPersonCode
SpecialCustomer
InsidePersonCode
AreaManagerCode
WorkerNo
Budget
Authors ,,
ComName Lustor, Inc.
CustomerFlag 1
BlockFlag
BlockDate
BlockMemo
BlockHistory
Distributor
SalesPerson
InsidePerson
AreaManager
IndustryClass01Code
IndustryClass01Name
IndustryClass02Code
IndustryClass02Name
UpdateDate
UpdateName xxxxx
ComType 1
OldComCode xxxxx
PreComCode
ComCode xxxxx
$UpdatedBy xxxxx

Can anyone help me?

--
Zigman- Skjul tekst i anførselstegn -

- Vis tekst i anførselstegn -




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with Arranging Excel Data! (pivots, transposing, etc) LoraHut Excel Discussion (Misc queries) 0 July 22nd 10 06:27 AM
transposing data in excel worksheet unknown Excel Programming 1 July 18th 08 06:29 AM
Excel 2002 Pivot Table: Can I use it for transposing data ? Mr. Low Excel Discussion (Misc queries) 6 October 13th 07 06:32 AM
Average score from repeating records? Ptyrider Excel Discussion (Misc queries) 4 October 4th 07 01:02 PM
Excel 2002: Any quick way of transposing data ? Mr. Low Excel Discussion (Misc queries) 1 July 18th 07 04:14 PM


All times are GMT +1. The time now is 10:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"