VBA- Clear Value From Refrance "A

sanju2323

New Member
Joined
Dec 12, 2013
Messages
17
[TABLE="class: grid, width: 246"]
<tbody>[TR]
[TD="colspan: 2, align: center"]Sample[/TD]
[TD="align: center"]Required Result[/TD]
[/TR]
[TR]
[TD="align: center"]Reference[/TD]
[TD="align: center"]Value[/TD]
[TD="align: center"]Value[/TD]
[/TR]
[TR]
[TD="align: center"]4.540[/TD]
[TD="align: center"]99.540[/TD]
[TD="align: center"]99.540[/TD]
[/TR]
[TR]
[TD="align: center"]3.750[/TD]
[TD="align: center"]99.720[/TD]
[TD="align: center"]99.720[/TD]
[/TR]
[TR]
[TD="align: center"]1.875[/TD]
[TD="align: center"]99.745[/TD]
[TD="align: center"]99.745[/TD]
[/TR]
[TR]
[TD="align: center"]0.000[/TD]
[TD="align: center"]99.790[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]1.875[/TD]
[TD="align: center"]99.745[/TD]
[TD="align: center"]99.745[/TD]
[/TR]
[TR]
[TD="align: center"]3.750[/TD]
[TD="align: center"]99.720[/TD]
[TD="align: center"]99.720[/TD]
[/TR]
[TR]
[TD="align: center"]4.600[/TD]
[TD="align: center"]99.505[/TD]
[TD="align: center"]99.505[/TD]
[/TR]
[TR]
[TD="align: center"]5.080[/TD]
[TD="align: center"]98.540[/TD]
[TD="align: center"]98.540[/TD]
[/TR]
[TR]
[TD="align: center"]3.750[/TD]
[TD="align: center"]99.580[/TD]
[TD="align: center"]99.580[/TD]
[/TR]
[TR]
[TD="align: center"]1.875[/TD]
[TD="align: center"]99.605[/TD]
[TD="align: center"]99.605[/TD]
[/TR]
[TR]
[TD="align: center"]0.000[/TD]
[TD="align: center"]99.650[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]1.875[/TD]
[TD="align: center"]99.605[/TD]
[TD="align: center"]99.605[/TD]
[/TR]
[TR]
[TD="align: center"]3.750[/TD]
[TD="align: center"]99.580[/TD]
[TD="align: center"]99.580[/TD]
[/TR]
[TR]
[TD="align: center"]5.120[/TD]
[TD="align: center"]98.275[/TD]
[TD="align: center"]98.275[/TD]
[/TR]
[TR]
[TD="align: center"]5.060[/TD]
[TD="align: center"]98.065[/TD]
[TD="align: center"]98.065[/TD]
[/TR]
[TR]
[TD="align: center"]3.750[/TD]
[TD="align: center"]99.330[/TD]
[TD="align: center"]99.330[/TD]
[/TR]
[TR]
[TD="align: center"]1.875[/TD]
[TD="align: center"]99.355[/TD]
[TD="align: center"]99.355[/TD]
[/TR]
[TR]
[TD="align: center"]0.000[/TD]
[TD="align: center"]99.400[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]1.875[/TD]
[TD="align: center"]99.355[/TD]
[TD="align: center"]99.355[/TD]
[/TR]
[TR]
[TD="align: center"]3.750[/TD]
[TD="align: center"]99.330[/TD]
[TD="align: center"]99.330[/TD]
[/TR]
[TR]
[TD="align: center"]5.130[/TD]
[TD="align: center"]97.850[/TD]
[TD="align: center"]97.850[/TD]
[/TR]
[TR]
[TD="align: center"]5.100[/TD]
[TD="align: center"]98.175[/TD]
[TD="align: center"]98.175[/TD]
[/TR]
[TR]
[TD="align: center"]3.750[/TD]
[TD="align: center"]99.350[/TD]
[TD="align: center"]99.350[/TD]
[/TR]
[TR]
[TD="align: center"]1.875[/TD]
[TD="align: center"]99.375[/TD]
[TD="align: center"]99.375[/TD]
[/TR]
</tbody>[/TABLE]

Column "A", where the zero value where the column "B" must be cleared in the Value


Sub Loop_Example()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long


With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With


'We use the ActiveSheet but you can replace this with
'Sheets("MySheet")if you want
With ActiveSheet


'We select the sheet so we can change the window view
.Select


'If you are in Page Break Preview Or Page Layout view go
'back to normal view, we do this for speed
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView


'Turn off Page Breaks, we do this for speed
.DisplayPageBreaks = False


'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row


'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1


'We check the values in the A column in this example
With .Cells(Lrow, "A")


If Not IsError(.Value) Then


If .Value = "0" Then .ClearContents
'This will delete each row with the Value "0"
'in Column A, case sensitive.


End If


End With


Next Lrow


End With


ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
 

Forum statistics

Threads
1,226,841
Messages
6,193,287
Members
453,788
Latest member
drcharle

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