Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 16th, 2007, 03:54 AM
Authorized User
Join Date: Apr 2007
Location: Silvassa, Dadra & Nagar Haveli, India.
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.

Reply With Quote
  #2 (permalink)  
Old May 16th, 2007, 02:26 PM
Friend of Wrox
Points: 513, Level: 8
Points: 513, Level: 8 Points: 513, Level: 8 Points: 513, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Feb 2007
Location: Davenport, IA, USA.
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts

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

End Sub
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 06:24 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.