if cell is empty

If cells G32,G33,G46,G47,J32,J33,J46,J47,M32,M33,M46,M47,P32,P33,P46,P47 and S32,S33,S46,S47 are empty I need to insert the word Care into each of these cells.

Can an expert provide me with VBA to do this please.
Who is Participating?
Saqib Husain, SyedEngineerCommented:
Range("G32,G33,G46,G47,J32,J33,J46,J47,M32,M33,M46,M47,P32,P33,P46,P47,S32,S33,S46,S47").SpecialCells(xlCellTypeBlanks).Value = "Care"
JagwarmanAuthor Commented:
Many thanks Saqib.
Haris DulicCommented:

attached is the Excel with function which will test if the cell is empty for supplied range and replace it with supplied replace string..

I prefer for these checks to create functions since the range can change and you can reuse it later on instead of hard coding the ranges...
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Rob HensonFinance AnalystCommented:
Alternatively, you can do it with formulas.

In four columns that are not currently used but are spaced the same as G, J, M, P and S ie two columns between, in rows 32, 33, 46 & 47:


You can then copy this whole block and paste special into the required area using Values and Skip Blanks options.

Rob H
Rodney EndrigaData AnalystCommented:
Here is the VBA code if you would like for the cells you specified:
Sub ee_FillCARE()
Dim rng As Range
Set rng = Range("G32,G33,G46,G47,J32,J33,J46,J47,M32,M33,M46,M47,P32,P33,P46,P47,S32,S33,S46,S47")
For Each cell In rng
    If IsEmpty(cell.Value) Or Trim(cell.Value) = vbNullString Then
        cell.Value = "Care"
    End If
Next cell
End Sub

Open in new window

This will check for Blank cells, SPACES in cells, and empty cells within your specified range and insert the word "Care" accordingly.
JagwarmanAuthor Commented:
I really don't like the points system on EE you all deserve top marks but I gave to Saqib Husain, Syed as he came in first and I had already used it.

But thank you all.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.