filtering weekly data (removing certain weeks)

jimjohn

Board Regular
Joined
Nov 14, 2007
Messages
108
hi, can someone please help me with this: i have weekly rate information in Excel. but i want to remove all other weeks and only include the first week of every month.

so my data looks like this:

Date Product CustRate
Nov 5, 2005 Mtg 4.5
Nov 5, 2005 Term 3.3
Nov 5, 2005 CD 2.3
Nov 12, 2005 Mtg 4.8
Nov 12, 2005 Term 6.6
Nov 12, 2005 CD 1.8
...

its not necessary that the first week always lands of the 5th day of the month sometimes its March 3rd, or so on.

any ideas how i can get rid of other data? Thanks a lot!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I am giving you a hybrid solution

see the sheet below

Excel Workbook
ABCDEF
1DateProductCustRateweekday offirst of monthdate in whichthe first week startslast date offirst week
25-Nov-05Mtg4.534-Nov-0511-Nov-05
35-Nov-05Term3.3
45-Nov-05CD2.3
512-Nov-05Mtg4.8
612-Nov-05Term6.6
712-Nov-05CD1.8
Sheet1


see the formulas in D2,E2,F2
once these formulas are done copy the sheet1 with formulas to sheet2
I have given step by step so that the formula can be understood easily.
If there are different months in column A you have to make to formulas you have to create the formulas for each month and run the macro modified
I hope you can do that.

now run this macro

Code:
Sub test()
Dim j As Integer, k As Integer
Worksheets("sheet1").Activate
j = Range("a1").End(xlDown).Row
For k = j To 2 Step -1
If Cells(k, 1) > CDate(Range("F2")) Or Cells(k, 1) < CDate(Range("E2")) Then Cells(k, 1).EntireRow.Delete
Next k
End Sub


the second macro is to undo(that is why copying sheet1 to sheet2 after formulas are activated.

Code:
Sub undo()
Worksheets("sheet1").Cells.Clear
Worksheets("sheet2").Cells.Copy Worksheets("sheet1").Range("A1")
End Sub

BEFORE RUNNING THE MACRO TO ORIGINAL FILE KEEP A COPY SOMEWHERE SAFE SO THAT THE DATA CAN BE RETRIEVED IF NECESSARY
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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