Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Copy unique entries

I wish to copy a list of entries to a new sheet.
If i use the code below it first copy's cell "b2" and then from the
last cell to the first.
Now i have a double entry.

I want it to end at cell b2, because the first cell has collum
headings in it!

How do i write the code so that cell b2 is not copied first?

kind regards

Sjoerd


this is my code:

Sub CopyUniqueEntries()

Dim uniquelist As range

Set uniquelist = ActiveSheet.range("A2", "A10000")

Sheet1.range("b2",
Sheet1.range("b65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=uniquelist.Cells(1, 1),
Unique:=True

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Copy unique entries

Advanced Filter has a requirement that the list have a header, that the
header be included in the list range, and the header will be pasted along
with the unique list. Since you start the range at B2, The Filter assumes
that is the header and copies it, and then the unique list. This why B2 is
copied twice. If you start your Range at B1 to include the header, then B2
will not be duplicated, but the header will be pasted in A2. Either way you
define your Filter range, the entry in A2 is unwanted and needs to be
deleted after the paste.
Also, your Paste To range need only be defined as one cell.

Sub CopyUniqueEntries()
Dim LastRow As Long

LastRow = Cells(Rows.Count, "B").End(xlUp).Row 'last data cell in col B
Range("B2:B" & LastRow).AdvancedFilter Action:=xlFilterCopy,
CopyToRange:=Range( _
"A2"), Unique:=True
Range("A2").Delete 'removes unwanted header
End Sub

Mike F
"Jumparound" wrote in message
oups.com...
I wish to copy a list of entries to a new sheet.
If i use the code below it first copy's cell "b2" and then from the
last cell to the first.
Now i have a double entry.

I want it to end at cell b2, because the first cell has collum
headings in it!

How do i write the code so that cell b2 is not copied first?

kind regards

Sjoerd


this is my code:

Sub CopyUniqueEntries()

Dim uniquelist As range

Set uniquelist = ActiveSheet.range("A2", "A10000")

Sheet1.range("b2",
Sheet1.range("b65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=uniquelist.Cells(1, 1),
Unique:=True

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Copy unique entries

Watch the word wrap on line 2.

Mike F
"Mike Fogleman" wrote in message
m...
Advanced Filter has a requirement that the list have a header, that the
header be included in the list range, and the header will be pasted along
with the unique list. Since you start the range at B2, The Filter assumes
that is the header and copies it, and then the unique list. This why B2 is
copied twice. If you start your Range at B1 to include the header, then B2
will not be duplicated, but the header will be pasted in A2. Either way
you define your Filter range, the entry in A2 is unwanted and needs to be
deleted after the paste.
Also, your Paste To range need only be defined as one cell.

Sub CopyUniqueEntries()
Dim LastRow As Long

LastRow = Cells(Rows.Count, "B").End(xlUp).Row 'last data cell in col B
Range("B2:B" & LastRow).AdvancedFilter Action:=xlFilterCopy,
CopyToRange:=Range( _
"A2"), Unique:=True
Range("A2").Delete 'removes unwanted header
End Sub

Mike F
"Jumparound" wrote in message
oups.com...
I wish to copy a list of entries to a new sheet.
If i use the code below it first copy's cell "b2" and then from the
last cell to the first.
Now i have a double entry.

I want it to end at cell b2, because the first cell has collum
headings in it!

How do i write the code so that cell b2 is not copied first?

kind regards

Sjoerd


this is my code:

Sub CopyUniqueEntries()

Dim uniquelist As range

Set uniquelist = ActiveSheet.range("A2", "A10000")

Sheet1.range("b2",
Sheet1.range("b65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=uniquelist.Cells(1, 1),
Unique:=True

End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy unique entries

Include A1 (with the real headers) in your unique list.
Put the advanced filter in B1 (that's where the header will be)
Your unique list will be in B2:B###

If you don't want the header in column B, then delete that cell (not the row)
and shift things up.

Jumparound wrote:

I wish to copy a list of entries to a new sheet.
If i use the code below it first copy's cell "b2" and then from the
last cell to the first.
Now i have a double entry.

I want it to end at cell b2, because the first cell has collum
headings in it!

How do i write the code so that cell b2 is not copied first?

kind regards

Sjoerd

this is my code:

Sub CopyUniqueEntries()

Dim uniquelist As range

Set uniquelist = ActiveSheet.range("A2", "A10000")

Sheet1.range("b2",
Sheet1.range("b65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=uniquelist.Cells(1, 1),
Unique:=True

End Sub


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Copy unique entries

On 3 sep, 14:50, Dave Peterson wrote:
Include A1 (with the real headers) in your unique list.
Put the advanced filter in B1 (that's where the header will be)
Your unique list will be in B2:B###

If you don't want the header in column B, then delete that cell (not the row)
and shift things up.





Jumparoundwrote:

I wish to copy a list of entries to a new sheet.
If i use the code below it first copy's cell "b2" and then from the
last cell to the first.
Now i have a double entry.


I want it to end at cell b2, because the first cell has collum
headings in it!


How do i write the code so that cell b2 is not copied first?


kind regards


Sjoerd


this is my code:


Sub CopyUniqueEntries()


Dim uniquelist As range


Set uniquelist = ActiveSheet.range("A2", "A10000")


Sheet1.range("b2",
Sheet1.range("b65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=uniquelist.Cells(1, 1),
Unique:=True


End Sub


--

Dave Peterson- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -


Tnx for the answers guys!

i figured i could delete the first entry right after copying, so i
made a makro to delete fhe first row aftert his one :)
but ill try to use your answers too!




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy unique entries

I'm not sure I understand.

But if you meant that you're not going to add headers and instead just delete
that first row (which would have been treated like a header), you may want to be
careful.

If that's the only entry that appears in the original list, you'd be deleting
one of the unique values.

I'd either add the headers first, do the advanced filter, then delete the
headers.

Or check to see if that "header" appears in the list further down before
deleting it.

Jumparound wrote:
<<snipped

i figured i could delete the first entry right after copying, so i
made a makro to delete fhe first row aftert his one :)
but ill try to use your answers too!


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Copy unique entries

On 4 sep, 17:29, Dave Peterson wrote:
I'm not sure I understand.

But if you meant that you're not going to add headers and instead just delete
that first row (which would have been treated like a header), you may want to be
careful.

If that's the only entry that appears in the original list, you'd be deleting
one of the unique values.

I'd either add the headers first, do the advanced filter, then delete the
headers.

Or check to see if that "header" appears in the list further down before
deleting it.

Jumparound wrote:

<<snipped



i figured i could delete the first entry right after copying, so i
made a makro to delete fhe first row aftert his one :)
but ill try to use your answers too!


--

Dave Peterson


Oke, this is what happends...

information get exported to excel
My macro kicks in.
I copy unique values from Sheet1.B:B to Sheet2.A2 (this includes the
header.)
Then i delete first row (Sheet2.A2 - the header from Sheet1.B1)
Then i clear empty spaces
Then i sort on name
"rest of the code executes"

This i a working way, have tested it on several documents.
Now im ready to try something else.

Code:
Sub CopyUniqueEntries()
Dim LastRow As Long


LastRow = Cells(Rows.Count, "B").End(xlUp).Row 'last data cell in col
B
Range("B2:B" & LastRow).AdvancedFilter Action:=xlFilterCopy,
CopyToRange:=Range( _
"A2"), Unique:=True
Range("A2").Delete 'removes unwanted header
End Sub
This look indeed like the code i need to use, now im ready to try it.

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
Unique entries jc132568 New Users to Excel 4 September 4th 09 05:02 AM
sum unique entries only Jo Excel Discussion (Misc queries) 0 April 30th 09 05:26 AM
Copy Unique Entries TimJames Excel Worksheet Functions 0 January 9th 08 03:23 PM
unique entries scrabtree[_2_] Excel Programming 7 August 1st 04 06:36 PM
Unique Entries John Phinney Excel Programming 3 April 6th 04 03:05 AM


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