Help writing simple code

thewiseguy

Well-known Member
Joined
May 23, 2005
Messages
818
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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
54,274
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
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>
 

thewiseguy

Well-known Member
Joined
May 23, 2005
Messages
818
Office Version
  1. 365
Platform
  1. Windows
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,706
Messages
5,833,238
Members
430,199
Latest member
Petty queen

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
Top