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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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,215,684
Messages
6,126,199
Members
449,298
Latest member
Jest

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