The Code Cage - Microsoft Office help Free Microsoft Office Help for all Applications!  

To stop seeing these ads and get other benefits check This page!

Go Back   The Code Cage Forums > Newsgroups - Microsoft Topics > Newsgroup - Excel Forum > Excel Miscellaneous


Excel Miscellaneous Post questions in this forum if they are related to using Microsoft Excel that doesn't quite fit in any other category e.g quirks, Formulae or built in functionality etc.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 26th June 2009, 06:12 AM
Faraz A. Qureshi
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default MACRO 2 COPY UNIQUES TO NEW SHEET

------ Register to get rid of these "In Post" ads! ------


Could one devise a macro to copy only uniques from a specific column(s) of
the "Selected" sheets to a new sheet? Because copying them all together on a
new sheet and then removing the duplicates won't be possible as the entries
in all might exceed the total rows of a single sheet.

Furthermore, the column of one of sheet might contain the entries already in
other sheet copied to the new sheet, the macro could also exclude such codes.

Thanx in advance 4 all your help.

--
Best Regards,

Faraz
Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
  #2 (permalink)  
Old 26th June 2009, 06:22 AM
Jacob Skaria
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default RE: MACRO 2 COPY UNIQUES TO NEW SHEET

------ Register to get rid of these "In Post" ads! ------


Faraz

Why dont you try Advanced Filter option. Suppose you have data in Sheet1;
and you want the unique list in Sheet2.

1. Assign a header to your column.
2. Activate Sheet2 and access the menu Data>Filter>Autofilter and 'Copy to
another location'.
3. In list range type the range Sheet1!A1:A5000
4. In copy to type/select cell A1
5. Check 'Unique records only'
6. Click OK will give you the unique list in Sheet2.

If this post helps click Yes
---------------
Jacob Skaria


"Faraz A. Qureshi" wrote:

> Could one devise a macro to copy only uniques from a specific column(s) of
> the "Selected" sheets to a new sheet? Because copying them all together on a
> new sheet and then removing the duplicates won't be possible as the entries
> in all might exceed the total rows of a single sheet.
>
> Furthermore, the column of one of sheet might contain the entries already in
> other sheet copied to the new sheet, the macro could also exclude such codes.
>
> Thanx in advance 4 all your help.
>
> --
> Best Regards,
>
> Faraz

Reply to this post


Did you find this post helpful? Yes | No
  #3 (permalink)  
Old 26th June 2009, 06:56 AM
Faraz A. Qureshi
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default RE: MACRO 2 COPY UNIQUES TO NEW SHEET

------ Register to get rid of these "In Post" ads! ------


Great Idea Jacob!

Thanx!!!

I am really thankful 4 all your help pal! However, can't the same task be
also conducted via a macro?

Thanx again.

--
Best Regards,

Faraz


"Jacob Skaria" wrote:

> Faraz
>
> Why dont you try Advanced Filter option. Suppose you have data in Sheet1;
> and you want the unique list in Sheet2.
>
> 1. Assign a header to your column.
> 2. Activate Sheet2 and access the menu Data>Filter>Autofilter and 'Copy to
> another location'.
> 3. In list range type the range Sheet1!A1:A5000
> 4. In copy to type/select cell A1
> 5. Check 'Unique records only'
> 6. Click OK will give you the unique list in Sheet2.
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Faraz A. Qureshi" wrote:
>
> > Could one devise a macro to copy only uniques from a specific column(s) of
> > the "Selected" sheets to a new sheet? Because copying them all together on a
> > new sheet and then removing the duplicates won't be possible as the entries
> > in all might exceed the total rows of a single sheet.
> >
> > Furthermore, the column of one of sheet might contain the entries already in
> > other sheet copied to the new sheet, the macro could also exclude such codes.
> >
> > Thanx in advance 4 all your help.
> >
> > --
> > Best Regards,
> >
> > Faraz

Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
  #4 (permalink)  
Old 26th June 2009, 07:14 AM
Jacob Skaria
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default RE: MACRO 2 COPY UNIQUES TO NEW SHEET

------ Register to get rid of these "In Post" ads! ------


Faraz

I have not replied with a macro coz you have posted your query in General
Questions; and I see you always in this group. No problems at all. Just for
your information. If you post your queries in the right group that might give
you a speedy response..and on top of that; this would help other users
searching for information in these groups..

For programming related
http://www.microsoft.com/office/comm...&lang=en&cr=US

For Worksheetfunctions
http://www.microsoft.com/office/comm...&lang=en&cr=US

Regarding the unique entries macro Certainly you can.. Try the below macro
which compares Sheet1 ColA and Sheet2 ColA. Adjust to suit your requirement.


Sub Macro()
Dim lngRow As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Dim lngLastRow1 As Long, lngLastrow2 As Long

Set ws1 = ActiveWorkbook.Sheets("Sheet1")
Set ws2 = ActiveWorkbook.Sheets("Sheet2")

lngLastRow1 = ws1.Cells(Rows.Count, "A").End(xlUp).Row
lngLastrow2 = ws2.Cells(Rows.Count, "A").End(xlUp).Row

For lngRow = 1 To lngLastRow1
If WorksheetFunction.CountIf(ws2.Range("A1:A" & _
lngLastrow2), ws1.Range("A" & lngRow)) = 0 Then
lngLastrow2 = lngLastrow2 + 1
ws2.Range("A" & lngLastrow2) = ws1.Range("A" & lngRow)
End If
Next
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Faraz A. Qureshi" wrote:

> Great Idea Jacob!
>
> Thanx!!!
>
> I am really thankful 4 all your help pal! However, can't the same task be
> also conducted via a macro?
>
> Thanx again.
>
> --
> Best Regards,
>
> Faraz
>
>
> "Jacob Skaria" wrote:
>
> > Faraz
> >
> > Why dont you try Advanced Filter option. Suppose you have data in Sheet1;
> > and you want the unique list in Sheet2.
> >
> > 1. Assign a header to your column.
> > 2. Activate Sheet2 and access the menu Data>Filter>Autofilter and 'Copy to
> > another location'.
> > 3. In list range type the range Sheet1!A1:A5000
> > 4. In copy to type/select cell A1
> > 5. Check 'Unique records only'
> > 6. Click OK will give you the unique list in Sheet2.
> >
> > If this post helps click Yes
> > ---------------
> > Jacob Skaria
> >
> >
> > "Faraz A. Qureshi" wrote:
> >
> > > Could one devise a macro to copy only uniques from a specific column(s) of
> > > the "Selected" sheets to a new sheet? Because copying them all together on a
> > > new sheet and then removing the duplicates won't be possible as the entries
> > > in all might exceed the total rows of a single sheet.
> > >
> > > Furthermore, the column of one of sheet might contain the entries already in
> > > other sheet copied to the new sheet, the macro could also exclude such codes.
> > >
> > > Thanx in advance 4 all your help.
> > >
> > > --
> > > Best Regards,
> > >
> > > Faraz

Reply to this post


Did you find this post helpful? Yes | No
  #5 (permalink)  
Old 26th June 2009, 08:01 AM
Faraz A. Qureshi
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default RE: MACRO 2 COPY UNIQUES TO NEW SHEET

------ Register to get rid of these "In Post" ads! ------


Thanx again Jacob,

However, usually I found the replies only in this group. But your guidance
in other other groups too will be helpful 4 sure

--
Best Regards,

Faraz


"Jacob Skaria" wrote:

> Faraz
>
> I have not replied with a macro coz you have posted your query in General
> Questions; and I see you always in this group. No problems at all. Just for
> your information. If you post your queries in the right group that might give
> you a speedy response..and on top of that; this would help other users
> searching for information in these groups..
>
> For programming related
> http://www.microsoft.com/office/comm...&lang=en&cr=US
>
> For Worksheetfunctions
> http://www.microsoft.com/office/comm...&lang=en&cr=US
>
> Regarding the unique entries macro Certainly you can.. Try the below macro
> which compares Sheet1 ColA and Sheet2 ColA. Adjust to suit your requirement.
>
>
> Sub Macro()
> Dim lngRow As Long
> Dim ws1 As Worksheet, ws2 As Worksheet
> Dim lngLastRow1 As Long, lngLastrow2 As Long
>
> Set ws1 = ActiveWorkbook.Sheets("Sheet1")
> Set ws2 = ActiveWorkbook.Sheets("Sheet2")
>
> lngLastRow1 = ws1.Cells(Rows.Count, "A").End(xlUp).Row
> lngLastrow2 = ws2.Cells(Rows.Count, "A").End(xlUp).Row
>
> For lngRow = 1 To lngLastRow1
> If WorksheetFunction.CountIf(ws2.Range("A1:A" & _
> lngLastrow2), ws1.Range("A" & lngRow)) = 0 Then
> lngLastrow2 = lngLastrow2 + 1
> ws2.Range("A" & lngLastrow2) = ws1.Range("A" & lngRow)
> End If
> Next
> End Sub
>
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Faraz A. Qureshi" wrote:
>
> > Great Idea Jacob!
> >
> > Thanx!!!
> >
> > I am really thankful 4 all your help pal! However, can't the same task be
> > also conducted via a macro?
> >
> > Thanx again.
> >
> > --
> > Best Regards,
> >
> > Faraz
> >
> >
> > "Jacob Skaria" wrote:
> >
> > > Faraz
> > >
> > > Why dont you try Advanced Filter option. Suppose you have data in Sheet1;
> > > and you want the unique list in Sheet2.
> > >
> > > 1. Assign a header to your column.
> > > 2. Activate Sheet2 and access the menu Data>Filter>Autofilter and 'Copy to
> > > another location'.
> > > 3. In list range type the range Sheet1!A1:A5000
> > > 4. In copy to type/select cell A1
> > > 5. Check 'Unique records only'
> > > 6. Click OK will give you the unique list in Sheet2.
> > >
> > > If this post helps click Yes
> > > ---------------
> > > Jacob Skaria
> > >
> > >
> > > "Faraz A. Qureshi" wrote:
> > >
> > > > Could one devise a macro to copy only uniques from a specific column(s) of
> > > > the "Selected" sheets to a new sheet? Because copying them all together on a
> > > > new sheet and then removing the duplicates won't be possible as the entries
> > > > in all might exceed the total rows of a single sheet.
> > > >
> > > > Furthermore, the column of one of sheet might contain the entries already in
> > > > other sheet copied to the new sheet, the macro could also exclude such codes.
> > > >
> > > > Thanx in advance 4 all your help.
> > > >
> > > > --
> > > > Best Regards,
> > > >
> > > > Faraz

Reply to this post


Did you find this post helpful? Yes | No
  #6 (permalink)  
Old 26th June 2009, 02:03 PM
Don Guillett
Newsgroup Contributor


My Top Tip Count:

 
Posts: n/a
Default Re: MACRO 2 COPY UNIQUES TO NEW SHEET

------ Register to get rid of these "In Post" ads! ------


Makes list and copies to UNused range and then deletes. Modify to suit

Sub MakeUniqueandcopytoothersheet()
Range("A1:B14").AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("h1"), Unique:=True
With Range(Range("h1"), Range("h1").End(xlDown))
..Copy Sheets("sheet5").Range("a9")
..Clear
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com
"Faraz A. Qureshi" <FarazAQureshi@discussions.microsoft.com> wrote in
message news:ED1D1FF8-1D3A-42F6-81A4-AC18AB9EDFD5@microsoft.com...
> Could one devise a macro to copy only uniques from a specific column(s) of
> the "Selected" sheets to a new sheet? Because copying them all together on
> a
> new sheet and then removing the duplicates won't be possible as the
> entries
> in all might exceed the total rows of a single sheet.
>
> Furthermore, the column of one of sheet might contain the entries already
> in
> other sheet copied to the new sheet, the macro could also exclude such
> codes.
>
> Thanx in advance 4 all your help.
>
> --
> Best Regards,
>
> Faraz


Reply to this post


Did you find this post helpful? Yes | No
The Code Cage Advertisment
Advertisement

To stop seeing these ads and get other benefits check This page!
Reply

Bookmarks

Tags
copy, macro, sheet, uniques

New topics in Excel Miscellaneous


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

The Code Cage Affilliates


To stop seeing these ads and get other benefits check This page!



All times are GMT +1. The time now is 05:41 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2
No part of this board may be copied or reproduced either in part or full without the express permission of The Code Cage Team.
We are not associated with nor employed by Microsoft in any way, we simply provide resources!
All MS office icons are registered trademarks of the application the represent