Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2007, 03:54 AM
Authorized User
 
Join Date: Apr 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Replace all cells having value <=zero

I would like to know how the cells having value less than or equal to zero can be replaced (Replace & make them blank) in a given range of cells / column.

Yogesh
__________________
Yogesh
 
Old May 16th, 2007, 02:26 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You could probably do this with a formula if the number is determined by calculation.

For example, this Formula could be 0 or negative:
=A1^2 - A2 - 5

This formula would return blank if 0 or negative:
=IF(A1^2 - A2 - 5 <= 0,"", A1^2 - A2 - 5)


Not sure what you're doing, but if it can't be rendered a formula then the code would be:
--------------------------------------------------------------------
Public Sub BlankBelow1(rPassedRange As Range)

'If value of cell is below 1 or text then clears content of cell.
  Dim rCurrent As Range
  For Each rCurrent In rPassedRange
    if Val(rCurrent.Value) <= 0 Then rCurrent.Value = "" 'Anything without positive numeric value blanked
  Next

End Sub
--------------------------------------------------------------------





Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace the cells having negative value yogeshyl Excel VBA 4 April 29th, 2016 01:43 PM
Replace "<enter>" with "<br>" Varg_88 Classic ASP Basics 5 February 14th, 2011 12:33 PM
line IN BETWEEN <td> cells (no border)? crmpicco HTML Code Clinic 2 August 31st, 2005 08:24 AM
Replace vbcrlf with <br> using C# kgriffin ASP.NET 1.0 and 1.1 Basics 2 May 4th, 2005 09:29 AM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.