Macro - If Cell in Column is Blank then input Text into Same row in another Column

tribalbydesign

New Member
Joined
Sep 15, 2008
Messages
20
Hello,

I am looking for a Macro that will search a column for blank cells, and when one is found will add text to the same row in another column. For example: The below is a spreadsheet. I am trying to find something that will search through column "C" in this case and add text (of my choice) to Column "A" if the cell is Blank. So Since cell C1 is Blank then Type "ERROR" is cell A1.
Code:
   A B C D E
1 X X    X X
2 X X    X X
3 X X X X X
4 X X X    X
5 X X X X
Thanks!
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Silly me, I put the first & outside of the quote marks, this should do it.

Code:
Range(y).Value = Evaluate(y & "& if(" & x & "<>"""", """"," & myChoice & ")")
 
Upvote 0
Hi all,
Sorry to dig out such an old topic but I have got very similar problem.

Dim myChoice
Dim x As String, y As String
myChoice = "A/R"
If Not IsNumeric(myChoice) Then myChoice = Chr(34) & myChoice & Chr(34)
x = Range("k1:k" & Range("g" & Rows.Count).End(xlUp).Row).Address
y = Range("g1:g" & Range("g" & Rows.Count).End(xlUp).Row).Address
Range(y).Value = Evaluate("if(" & x & "<>""""," & y & "," & myChoice & ")")

That is a small part of my macro, the problem is that at the moment when excel finds blank cell in column K it will replace whatever is in the same row in column G with A/R and I would like it to add A/R not replace the data. Sorry for my english, thanks in advance!
Lukasz
try
Code:
Range(y).Value = Evaluate("if(" & x & "<>""""," & y & "," & y & myChoice & ")")
 
Upvote 0

Forum statistics

Threads
1,216,140
Messages
6,129,105
Members
449,486
Latest member
malcolmlyle

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