Help writing simple code

thewiseguy

Well-known Member
Joined
May 23, 2005
Messages
956
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

Trying to write a simple code. Here is what I am trying to do:

In sheet "DETAIL1" from cell B4 to B316, wherever the value is "0," clear the contents of the entire row (but not column A).

Hope that is clear and any help is greatly appreciated!


-twg
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi everyone,

Trying to write a simple code. Here is what I am trying to do:

In sheet "DETAIL1" from cell B4 to B316, wherever the value is "0," clear the contents of the entire row (but not column A).

Hope that is clear and any help is greatly appreciated!


-twg
Try this. I'm assuming there is something in B3.

<font face=Courier New><br><br><SPAN style="color:#00007F">Sub</SPAN> ClearZeroRows()<br>    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    <SPAN style="color:#00007F">With</SPAN> Sheets("DETAIL1").Range("B3:B316").Resize(, Columns.Count - 1)<br>        .AutoFilter Field:=1, Criteria1:="=0"<br>        <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN><br>            .Offset(1).Resize(313).SpecialCells(xlCellTypeVisible).ClearContents<br>        <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> 0<br>        .AutoFilter<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
Try this. I'm assuming there is something in B3.

<font face=Courier New><br><br><SPAN style="color:#00007F">Sub</SPAN> ClearZeroRows()<br>****Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>****<SPAN style="color:#00007F">With</SPAN> Sheets("DETAIL1").Range("B3:B316").Resize(, Columns.Count - 1)<br>********.AutoFilter Field:=1, Criteria1:="=0"<br>********<SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN><br>************.Offset(1).Resize(313).SpecialCells(xlCellTypeVisible).ClearContents<br>********<SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> 0<br>********.AutoFilter<br>****<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>****Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>



that worked perfectly peter...thank you.
 
Upvote 0

Forum statistics

Threads
1,215,506
Messages
6,125,193
Members
449,213
Latest member
Kirbito

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