Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 553
Default COLUMN WITH UNEQUAL BLOCKS TO TABLE

Dear Fellows,

The problem is that I commonly have a very large list imported from .txt to
..xls or .xlsx which has the blocks not of common/equal size.

An example is Column "A" showing:

Name: 1
Department: 1
Cell: xxx
Email:
Name: 2
Department: 2
Cell: yyy
Res: xxx
Email:

Name: 3
Department: 3
Cell: xxx

However, note that every new block starts with "Name" as the first 4
characters. Any idea how to convert such a data to:

Name: 1 Name: 2 Name: 3
Department: 1 Department: 2 Department: 3
Cell: xxx Cell: xxx Cell: xxx
Email:
Res: xxx Email:

Your help, a fortmula or a code and guidance shall highly obliged!

--
Best Regards,
FARAZ A. QURESHI
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default COLUMN WITH UNEQUAL BLOCKS TO TABLE

Try code like the following. Change the lines marked with "<<<" to the
appropriate values:

Sub VarColToTable()
Dim R As Range
Dim Dest As Range
Dim DR As Range
Dim LastRow As Long
Dim SourceWS As Worksheet
Dim DestinationWS As Worksheet

Set SourceWS = Worksheets("Sheet1") '<<< CHANGE
Set DestinationWS = Worksheets("Sheet2") '<<< CHANGE
Set R = SourceWS.Range("A1") '<<< CHANGE

With SourceWS
LastRow = .Cells(.Rows.Count, R.Column).End(xlUp).Row
End With

Do Until R.Row LastRow
If UCase(R.Text) Like "NAME*" Then
If Dest Is Nothing Then
Set Dest = DestinationWS.Range("E1") '<<< CHANGE
Else
Set Dest = Dest(1, 2)
End If
Set DR = Dest
End If
DR.Value = R.Text
Set DR = DR(2, 1)
Set R = R(2, 1)
Loop
MsgBox "Data split on '" & DestinationWS.Name & "'."
End Sub

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Wed, 17 Dec 2008 04:44:21 -0800, FARAZ QURESHI
wrote:

Dear Fellows,

The problem is that I commonly have a very large list imported from .txt to
.xls or .xlsx which has the blocks not of common/equal size.

An example is Column "A" showing:

Name: 1
Department: 1
Cell: xxx
Email:
Name: 2
Department: 2
Cell: yyy
Res: xxx
Email:

Name: 3
Department: 3
Cell: xxx

However, note that every new block starts with "Name" as the first 4
characters. Any idea how to convert such a data to:

Name: 1 Name: 2 Name: 3
Department: 1 Department: 2 Department: 3
Cell: xxx Cell: xxx Cell: xxx
Email:
Res: xxx Email:

Your help, a fortmula or a code and guidance shall highly obliged!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 553
Default COLUMN WITH UNEQUAL BLOCKS TO TABLE

U R simply the best CHIP!!!!!!!!!!!!!!!

Thanx!!!!

Yours ever-admiring fan!
--

Best Regards,
FARAZ A. QURESHI


"Chip Pearson" wrote:

Try code like the following. Change the lines marked with "<<<" to the
appropriate values:

Sub VarColToTable()
Dim R As Range
Dim Dest As Range
Dim DR As Range
Dim LastRow As Long
Dim SourceWS As Worksheet
Dim DestinationWS As Worksheet

Set SourceWS = Worksheets("Sheet1") '<<< CHANGE
Set DestinationWS = Worksheets("Sheet2") '<<< CHANGE
Set R = SourceWS.Range("A1") '<<< CHANGE

With SourceWS
LastRow = .Cells(.Rows.Count, R.Column).End(xlUp).Row
End With

Do Until R.Row LastRow
If UCase(R.Text) Like "NAME*" Then
If Dest Is Nothing Then
Set Dest = DestinationWS.Range("E1") '<<< CHANGE
Else
Set Dest = Dest(1, 2)
End If
Set DR = Dest
End If
DR.Value = R.Text
Set DR = DR(2, 1)
Set R = R(2, 1)
Loop
MsgBox "Data split on '" & DestinationWS.Name & "'."
End Sub

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Wed, 17 Dec 2008 04:44:21 -0800, FARAZ QURESHI
wrote:

Dear Fellows,

The problem is that I commonly have a very large list imported from .txt to
.xls or .xlsx which has the blocks not of common/equal size.

An example is Column "A" showing:

Name: 1
Department: 1
Cell: xxx
Email:
Name: 2
Department: 2
Cell: yyy
Res: xxx
Email:

Name: 3
Department: 3
Cell: xxx

However, note that every new block starts with "Name" as the first 4
characters. Any idea how to convert such a data to:

Name: 1 Name: 2 Name: 3
Department: 1 Department: 2 Department: 3
Cell: xxx Cell: xxx Cell: xxx
Email:
Res: xxx Email:

Your help, a fortmula or a code and guidance shall highly obliged!


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
What is results table mean for-t-TestTwoSample unequal variance Dilia Excel Discussion (Misc queries) 1 October 31st 08 04:05 PM
Formula Bar blocks column header letters so I can't paste Clueless in Seattle New Users to Excel 3 November 21st 07 09:50 PM
Multiple blocks (double column lists) turned into drop down list Mister_Paul_K Excel Discussion (Misc queries) 0 March 30th 07 10:00 AM
lookup and choose wih multiple tables of unequal column lengths Lew Excel Discussion (Misc queries) 8 January 2nd 06 11:38 PM
unequal sign et Excel Discussion (Misc queries) 2 February 6th 05 11:17 PM


All times are GMT +1. The time now is 11:15 AM.

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"