oh no!! Another delete row based on cell value question!!

MarkRush

New Member
Joined
Mar 6, 2018
Messages
28
SO I have a macro that i am using to create a specific report for my users to show them the values that are being used to calculate a value based on their input to the workbook. The macro first checks to see if the worksheet laborreport is present and if so deleted the current version of that work sheet. It then seletcs another sheet and clears the contents. of a range of cells, Seletcs the next worksheet( labor -final) and copies a range of cells to the OE2 worksheet. It then copies the worksheet OE2 to a new worksheet and names it laborreport.

Finally i Want it to check column H Cell 3 thru 400 and if the value = 0 delete the row. Everything works except the deletion of the row.. teh macro does complete and does not give me an error message
here is the Macro:

Sub laborreport()


Sheets("Main").Select


Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual


For Each Sheet In ActiveWorkbook.Worksheets
If Sheet.Name = "laborreport" Then
Application.DisplayAlerts = False
Worksheets("laborreport").Delete
Application.DisplayAlerts = True
End If
Next Sheet


Sheets("OE2").Range("A4:F400").clearcontents
Sheets("Labor -Final").Range("A9:F369").Copy
ActiveWorkbook.Sheets("OE2").Range("A3").PasteSpecial Paste:=xlValues
Sheets("oe2").Copy after:=Sheets("summary")
ActiveSheet.Name = "laborreport"


With Sheets("laborreport")




BeginRow = 3
Endrow = 400
ChkCol = 8





For RowCnt = BeginRow To Endrow
If Cells(RowCnt, ChkCol).Value < 0.001 Then
Cells(RowCnt, ChkCol).EntireRow.Delete
End If
Next RowCnt
End With


Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic


Sheets("laborreport").Select
Range("a1").Select
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Code:
For RowCnt = EndRow To Beginrow Step -1
 
Upvote 0
for next time...normally we do go from top to bottom but when deleting rows the count misses a step as it is then the row number it was on before the deletion and so steps over it.
 
Upvote 0

Forum statistics

Threads
1,215,056
Messages
6,122,907
Members
449,096
Latest member
dbomb1414

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