LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Seperate Repeating Info into One Line while deleting others

Try this

Sub Test()
Dim myCell As Range
Dim aWS As Worksheet
Dim lRow As Long
Dim myDeleteRange As Range

Set aWS = ActiveSheet
lRow = aWS.Cells(aWS.Rows.Count, 1).End(xlUp).row
Set myCell = aWS.Range("A1") '<~~~change first cell as needed

Do
If myCell.Offset(1, 0).Value = myCell.Value Then
lcol = aWS.Cells(myCell.row, aWS.Columns.Count).End(xlToLeft).Column
+ 1
myCell.Offset(0, lcol - myCell.Column).Value = myCell.Offset(1,
1).Value
If myDeleteRange Is Nothing Then
Set myDeleteRange = myCell.Offset(1, 0)
Else
Set myDeleteRange = Union(myDeleteRange, myCell.Offset(1, 0))
End If

End If
Set myCell = myCell.Offset(1, 0)

Loop While myCell.row < lRow

If Not myDeleteRange Is Nothing Then
Debug.Print myDeleteRange.Address
myDeleteRange.EntireRow.Delete
End If

End Sub

--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



" wrote:

Hi -

I'm trying to seperate out repeating info (last column has unique
data) and place them into a new line.

For example:

12345 CBB
12345 GGG
54321 PPP
99999 BBB
99999 AXZ

Would turn into

12345 CBB GGG
54321 PPP
99999 BBB AXZ

I've been trying to do this through a macro by reading in every row
and matching if the first column matches the second column then take
whats in the first column and place into the last column then delete
the first row.

But I havn't found a great way in code to do this yet. My first
problem is that I can't determine how many times the number would
repeat so I don't know how many columns to go over etc...

Thanks for any help on this,

- Tek

 
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
Seperate info in a cell Petert[_2_] Excel Worksheet Functions 8 January 5th 10 04:27 PM
Repeating Info Change Junderwood57 Excel Discussion (Misc queries) 1 September 25th 08 04:55 PM
HOW DO I SEPERATE INFO FROM ONE INTO TWO COLUMNS? help needed Excel Worksheet Functions 2 August 12th 06 12:01 AM
Repeating Characters in Cells with info. Stressed Student Excel Discussion (Misc queries) 3 December 8th 05 05:10 PM
How do I remove repeating line in Excell - Top line on each page.. keepon Excel Worksheet Functions 1 March 23rd 05 11:26 PM


All times are GMT +1. The time now is 06:19 PM.

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

About Us

"It's about Microsoft Excel"