Simple code to clear cell if another cell has no value

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Evening,
Red arrow column H
Blue Arrow column J
Green arrow column M

For your information column M has the following code then down the page to row 36
Rich (BB code):
=IF(AND(H27="",J27=""),"",H27*J27)

Im trying to clear the text in column / cells J if no value is in column / cells H

Example.
Currenly cell H27 has a value of 1 & cell J27 has a value of £10.00
If i delete the 1 in cell H27 i require the value in cell J27 to be deleted so the cell is empty.

I tried the following down to row 36 but nothinh happened when the Hcell value was removed
Rich (BB code):
If Range("H27").Value = "" Then Range("J27").Value = ""
If Range("H28").Value = "" Then Range("J28").Value = ""
If Range("H29").Value = "" Then Range("J29").Value = ""
 

Attachments

  • 2722.jpg
    2722.jpg
    83.8 KB · Views: 4

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
If the cell is not empty, then there is something in it. You could change some code to investigate what happens when you delete the cell.

VBA Code:
    If Range("H27").Value = "" Then
        Range("J27").Value = ""
    Else
        MsgBox "H27 Ascii code: " & Asc(Left(Range("H27").Value, 1)), , "Cell not empty"
    End If

Issues I've seen are that the cell has space characters or sometimes the null char (ascii 160) that make you think the cell has no value when it does.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,808
Messages
6,121,686
Members
449,048
Latest member
81jamesacct

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