#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Sub Group

Option Explicit

Sub Group()

Dim rFind As Range, sAddress As String, rng As Range, c As Long, n As Long,
r As Long

c = 3: r = 1
Sheets("Sheet2").UsedRange.Clear
With Sheets("Sheet1")
For Each rng In .Range("A1", .Range("A1").End(xlDown))
Sheets("Sheet2").Cells(r, 1).Resize(, 2).Value = rng.Resize(, 2).Value
n = Sheets("Sheet2").Cells.Find(What:="*", LookAt:=xlWhole,
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Do While c < 20
r = n
With .Columns(c)
Set rFind = .Find(What:=rng, LookIn:=xlFormulas,
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False,
SearchFormat:=False)
If Not rFind Is Nothing Then
sAddress = rFind.Address
Do
If c < 13 Then
Sheets("Sheet2").Cells(r, c).Resize(, 2).Value =
rFind.Resize(, 2).Value
Else
Sheets("Sheet2").Cells(r, c).Resize(, 3).Value =
rFind.Resize(, 3).Value
End If
r = r + 1
Set rFind = .FindNext(rFind)
Loop While rFind.Address < sAddress
End If
End With
If c < 13 Then
c = c + 2
Else
c = c + 3
End If
Loop
c = 3
r = Sheets("Sheet2").Cells.Find(What:="*", LookAt:=xlWhole,
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
Next rng
End With

End Sub

Right now this code

1. Goes to Sheet1 and looks at the contents in Column A then looks for a
duplicate of those contents in Column C, Column E, Column G, Column I, Column
K, Column M, Column P, and Column S.

2. When Column A has duplicates in
Column C
Column E
Column G
Column I
Column K
Column M
Column P
Column S

This macro copies that row of..
Columns A plus Column B
Columns C plus Column D
Columns E plus Column F
Columns G plus Column H
Columns I plus Column J
Columns K plus Column L
Columns M plus Column N and Column O
Columns P plus Column Q and Column R
Columns S plus Column T and Column U

Goes to Sheet2 and pastes those different rows into the same row, so
Column A:B
Column C:D
Column E:F
Column G:H
Column I:J
Column K:L
Column M:O
Column Q:R
Column T:U
are all in the same row

I am looking for help so the macro will do this instead.

In Sheet1 when Column A has duplicates in
Column C
Column F
Column I

I would like to copy that row of..
Column A plus Column B
Column C plus Column D and Column E
Column F plus Column G and Column H
Column I plus Column J, Column K, and Column L

3. Then Go to Sheet2 paste those different rows into the same row, so
Column A:B
Column C:E
Column F:H
Column I:L
Would all be in the same row

Thank you for your help.

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
Range.Group Method - group rows, not columns serhio[_2_] Excel Programming 1 May 7th 08 01:26 PM
Group a range - closing the group does not hide the controls.... [email protected] Excel Programming 0 April 21st 07 04:53 AM
Sort by Group Header or by Group SubHeader Aria[_2_] Excel Programming 4 February 28th 07 01:07 AM
Taking age group Ie ages 20-29 and picking out net sales for group viabello Excel Worksheet Functions 1 April 25th 06 04:19 AM
How do I group worksheets (Lotus 123 function is "Sheet>Group Shee jaking Excel Worksheet Functions 2 August 30th 05 02:09 PM


All times are GMT +1. The time now is 03:38 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"