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.
JagwarmanAsked:
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"
0
 
JagwarmanAuthor Commented:
Many thanks Saqib.
0
 
Haris DulicCommented:
Hi,

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...
Book1---Copy.xlsm
0
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:

=IF(G32="","Care","")

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

Thanks
Rob H
0
 
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.
0
 
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.
0
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.