Macro to delete excessive rows

ses0518

New Member
Joined
Jan 11, 2012
Messages
3
I am having a hard time figuring this out and was hoping for a little help. I need a macro that looks at a specific calculated cell and deletes all data past that row. I have been looking and trying to write code to do this but can't seem to get what I want... Any ideas
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
first line selects the first empty row
the next selects down to the bottom of the worksheet
and the last deletes


Rows("13:13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp

theres a start

Not enough info on the specific cell
 
Upvote 0
If I understand what you want, this should do the trick:

Code:
Sub DeleteRows()
Dim x As Integer
    For x = 2 To WorksheetFunction.CountA(Range("Sheet1!E:E")-1)
        If Range("E" & x).Value = "My Value" Then
            Range("F" & x & (":IV" & x)).ClearContents
        End If
    Next x
End Sub

Just change "My Value" to whatever the actual value is and adjust the column refrences.
 
Upvote 0
So I guess maybe I am unclear as what I am trying to do. The macro is for selecting data for audit. The macro first counts the rows, once the rows are counted, it places this total in AL1. It then looks at a table to determine what the initial sampling will be and places that number in AL2, then it places the expanded number in AL3. Then macro then sums this number and places that total into AL4. So example, universe of 372, initial sample is 30, the expanded is 38, the total is 68. In this example I want to delete the remaining 304 rows of data. The first row is a header. Does this make sense????
 
Upvote 0
Bjurney,

Thanks for the code, but I still can't seem to get it to do what I want....I still trying to figure it out, but it is driving me insane
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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