Deleting Rows where Column A contains a date before...

plfas

New Member
Joined
Aug 26, 2014
Messages
13
So I've got a lot of help on these boards, but I need some more.

I import some raw survey response data on the first two sheets, named English and French respectively. My current macro splits the timestamp in column "A" into separate date and time columns. It then deletes surveys abandoned on the first question and adds some NPS calculations in columns S and T.

The raw data for the responses comes from the entire time period the survey has been running. What I need to do is turn this into a weekly report.

In an ideal world, the user would be prompted to enter a start and end date for the report. It would then delete the entire row that contains dates in column A outside of that range.

I don't know this is possible, as my "Master" macro that calls this sub routine turns off screen updating, display alerts and automatic calculation. Otherwise, my code takes literally 30 minutes to run.

In a less ideal world, it would simply delete all responses (rows) that are more than a week old.


Here is my code that runs on the "raw data" sheets:
Code:
Sub SplitDate()



    Dim wrkSht As Worksheet
    Dim i As Long
    
    For Each wrkSht In ThisWorkbook.Worksheets
        If wrkSht.Name = "English" Or wrkSht.Name = "French" Then
            With wrkSht




                '
                ' Splits Date & Time into two columns
                '
                    .Columns("B:B").Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
                    .Range("A:A").TextToColumns Destination:=.Range("A:A"), DataType:=xlDelimited, _
                        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
                        Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
                        :=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
                    
                'Deletes responses abandoned on first question
                
                
                Dim LastRow As Long
                LastRow = .Range("A65536").End(xlUp).Row
                
                For i = LastRow To 1 Step -1
                If .Cells(i, 6) = "Abandoned" Then .Rows(i & ":" & i).EntireRow.Delete
                Application.ScreenUpdating = False
                Next i
                
                
                '' Adds Promoters,Detractors, etc to columns t/u
                
                
                Dim endrow As Long
                endrow = .UsedRange.SpecialCells(xlCellTypeLastCell).Row
                                
                .Range("S3").FormulaR1C1 = _
                        "=IF(RC[-12]=""Unattempted"",""N/A"",IF(RC[-12]=""Abandoned"",""N/a"",IF(RC[-12]>8,""Promoter"",IF(RC[-12]>6,""Passive"",""Detractor""))))"
                .Range("S3").AutoFill Destination:=.Range("S3:S" & endrow), Type:=xlFillDefault
                
                .Range("T3").FormulaR1C1 = _
                        "=IF(RC[-9]=""Unattempted"",""N/A"",IF(RC[-9]=""Abandoned"",""N/a"",IF(RC[-9]>8,""Promoter"",IF(RC[-9]>6,""Passive"",""Detractor""))))"
                .Range("T3").AutoFill Destination:=.Range("T3:T" & endrow), Type:=xlFillDefault
            End With
        End If




    Next wrkSht




End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

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