Run code only if adjacent cell is blank

EssKayKay

Well-known Member
Joined
Jan 5, 2003
Messages
504
Office Version
  1. 2007
Platform
  1. Windows
Hello,

I have a VBA routine that does most of what I want. What I’m trying to do is add one more parameter to one line in the code. I think this will work but am not positive. Here is the code I received from a kind member here that mostly works:
Rich (BB code):
Range("T33:T133").SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=IF(RC[-2]<=R27C21,1,"""")"

What I want is the cells in the range in column “T” to only be updated if the cell directly to the left in column “S” is blank or not populated (i.e., <=0). Column S is formatted as currency; column T is formatted as date.

Thanks for viewing,
Steve
 
Your condition/explanation is a bit confusing. "<=0" is very different than "blank or not populated". For example, -4 is a negative number, and certainly not blank.
Can you try explaining your conditions more clearly and concisely?
 
Upvote 0
If your really just want to enter the formulas in column T if column S of the same row is blank/empty, you could use this:
VBA Code:
Range("S33:S133").SpecialCells(xlCellTypeBlanks).Offset(0, 1).FormulaR1C1 = "=IF(RC[-2]<=R27C21,1,"""")"
 
Upvote 0
Solution
Your condition/explanation is a bit confusing. "<=0" is very different than "blank or not populated". For example, -4 is a negative number, and certainly not blank.
Can you try explaining your conditions more clearly and concisely?
Ahh thank you Joe for responding. I believe you are the gentleman who assisted me in the code to begin with - so much appreciated.

I should have probably just said blank cell. No cells in column "S" should ever be negative or probably even zero.
Here is a bit more of the code that may help. I believe this is where the later part of the code is used [ "=IF(RC[-2]&lt;=R27C21,1,"""") ].

Rich (BB code):
    If Year(Range("M32").End(xlDown).Offset(0, -10)) = Year(Range("M32").End(xlDown).Offset(1, -10)) Then
       Range("U27") = Year(Range("M32").End(xlDown).Offset(0, -10)) - 1
     Else
       Range("U27") = Year(Range("M32").End(xlDown).Offset(0, -10))
    End If

Here's a screen shot:

1742827088565.jpeg


In the above example I'd only what to update cells T36, T37, & T39.

Thanks,
Steve K.
 

Attachments

  • 1742826853353.jpeg
    1742826853353.jpeg
    46.2 KB · Views: 6
Upvote 0
I should have probably just said blank cell. No cells in column "S" should ever be negative or probably even zero.
OK, if that is the case, I think the formula I posted in my previous post should do what you want.
 
Upvote 0
OK, if that is the case, I think the formula I posted in my previous post should do what you want.
Thank you Joe your code appears to be doing exactly what I had in mind. Apparently I was posting while you did.

Again - so much appreciated,
Steve
 
Upvote 0
You are welcome.
Glad I was able to help!
:)
 
Upvote 0

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