Macro Magic Required

mikemcbain

Board Regular
Joined
Nov 14, 2005
Messages
152
Office Version
  1. 365
Platform
  1. Windows
I use Office 365 and xlsx and xlsm and the occasional old xls file.
I have a large xls workbook which includes Sheets called Today and Best.
On my Today sheet which changes each day I have Columns E to CH sorted by Column Z which has dates in descending Date order, somedays just one Row per Date but somedays there can be up to 20 Rows with the same Date and perhaps 50 different dates.Column N called ARATE is a secondary sort column.
Now here is my problem....I want to copy only the first Row of each date to my worksheet called Best.
I will attach a before and after screen shot
It is so tedious doing it manually.
With thanks for your patience and assistance.
Old Mike.
 

Attachments

  • Capture1.PNG
    Capture1.PNG
    139.7 KB · Views: 5
  • Capture2.PNG
    Capture2.PNG
    112.6 KB · Views: 5
Great! (y)


In that case I would suggest this which removes the 'Best' sheet (code assumes that sheet does exist) and duplicates 'Today' which would preserve all formatting, column widths etc before removing the required rows all at the one time on the new 'Best' sheet.

VBA Code:
Sub FirstDateOnly_v2()
  Application.DisplayAlerts = False
  Sheets("Best").Delete
  Application.DisplayAlerts = True
  Sheets("Today").Copy After:=Sheets("Today")
  With ActiveSheet
    .UsedRange.RemoveDuplicates Columns:=26, Header:=xlYes
    .Name = "Best"
  End With
End Sub
Thanks again Peter.
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You are welcome. Thanks for the follow-up.

BTW, you have a post marked as the accepted solution that is clearly not a solution. Perhaps you meant to mark that one with a 'Like'? ?
So you should at least unmark that one but then you can decide yourself if you want to mark one of the others as the accepted solution. :)
 
Upvote 0
@Peter_SSs
I don't think there will ever be a solution for being 68.......except being 69.....:cry:
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top