LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
external usenet poster
 
Posts: 5
Default Same operations on a variable number of rows

On Wed, 6 Apr 2005 10:38:08 -0400, in microsoft.public.excel , "Tom
Ogilvy" in
wrote:

assuming data starts in A1 and there are no headers in the first row.

Sub GetUniques()
Dim rng As Range
Dim cell As Range
Dim rng1 As Range
Set rng = Range(Cells(1, "A"), Cells(Rows.Count, "A").End(xlUp))
For Each cell In rng
Cells(cell.Row, "C").Value = cell.Value & _
cell.Offset(0, 1).Value
Next
Cells(1, "C").Insert Shift:=xlShiftDown
Cells(1, "C").Value = "Header"
Set rng1 = Range(Cells(1, "C"), Cells(1, "C").End(xlDown))
rng1.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Cells(1, "D"), _
Unique:=True
Cells(1, "C").Resize(1, 2).Delete Shift:=xlShiftUp
End Sub

This method doesn't use concatenation and the results are not concatenated,
however the unique results are the same if you did concatenate them.


I think I understand this enough to make it do what I want. Thanks for
a very large help.


Sub GetUniquesAlternate()
Range("A1:B1").Insert Shift:=xlDown
Range("A1:B1").Value = _
Array("Header1", "Header2")
Range("A1").CurrentRegion.Resize(, 2) _
.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Cells(1, "C"), _
Unique:=True
Range("A1:D1").Delete Shift:=xlShiftUp
End Sub


More compact, but harder for me to do more processing. Thanks again.


--
Matt Silberstein

All in all, if I could be any animal, I would want to be
a duck or a goose. They can fly, walk, and swim. Plus,
there there is a certain satisfaction knowing that at the
end of your life you will taste good with an orange sauce
or, in the case of a goose, a chestnut stuffing.
 
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
Summing a variable number of rows CEGavinMcGrath Excel Discussion (Misc queries) 4 August 28th 08 10:03 PM
copy down with variable number of rows mohavv Excel Discussion (Misc queries) 5 November 15th 07 04:18 PM
Linking to a Variable Number of Rows - XP/07 RFJ Excel Worksheet Functions 4 May 17th 07 07:53 PM
Paste to variable number of rows brook6 Excel Programming 0 April 5th 04 09:36 PM
deleting variable number of rows Nick Excel Programming 1 October 29th 03 04:31 PM


All times are GMT +1. The time now is 07:03 AM.

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"