Assistance With Macro (Zero Remove)

Russ At Index

Well-known Member
Joined
Sep 23, 2002
Messages
706
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
Morning ,

I have the following snippet of code which , whaen run should
remove from my spreadsheet all the zeros ("0") from column G.

Sub myDeleteRows()
'
' ReturnsDescrepancyV1DeleteZeroRows Macro Russ ****ings 18/09/2010
'

'


Dim MyCol As String
Dim MyVal As Variant
Dim i As Integer

MyCol = InputBox("column to look through", "Column Search", "G")
MyVal = InputBox("Value to look for", "search value", 0)
For i = 1 To Range(MyCol & "65536").End(xlUp).Row Step 1
If Application.WorksheetFunction.CountIf(Range("G" & i & ":AZ" & i), MyVal) > 0 Then
Range("G" & i).EntireRow.Delete
End If
Next i

End Sub

Alas it leaves the one row were the answer is correct & removes
7 of the zero rows but leaves 6 showing as 0 !!!

Any help , as ever appreciated,

TIA

Russ
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try going backwards

For i = Range(MyCol & "65536").End(xlUp).Row to 1 Step -1
 
Upvote 0
Hi VoG ,

Long time no speak , once again , you have saved my day ,
code is now performing as i thought it should have done !!!

Have a great day ,

Thanks Mate ,

Russ
 
Upvote 0

Forum statistics

Threads
1,215,483
Messages
6,125,064
Members
449,206
Latest member
Healthydogs

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