Input specific value into cell if Row has data

P

PVANS

Hi there,

I have a worksheet ("Results") that has several rows of data - in specific
columns. I now need to add a specific value into the blank columns of these
rows of data:

Before:
A B C D E
1 coke 24 xxx
2 coke 18 xxx

After
A B C D E
1 coke TRUE 24 xxx
2 coke TRUE 18 xxx

The specific value will be the same on every row. I am able to add this
value to every line regardless of whether there is data in that row, however,
I ideally only want it when there is data in row.

Can someone help me please? If I have been unclear, I will be more than
willing to provide more information should it be required.

Regards
 
E

Eduardo

Hi,
If I didn't misunderstand this formula should work

=IF(COUNTA(C8:E8)>0,"TRUE","")

if any of the cells in the row have data will enter True otherwise will be
blank
 
G

Gary''s Student

Try this:

Sub PutValue()
Dim specific As String
Dim columnn As String
Dim n As Long, i As Long
specific = "TRUE"
columnn = "C"
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
If Application.WorksheetFunction.CountA(Rows(i)) <> 0 Then
Cells(i, columnn).Value = specific
End If
Next
End Sub
 
R

Rick Rothstein

I'm not completely clear on what you are looking to do. Is Column C the only
column that you want to put the word TRUE in or did you want to put that
word into each blank cell on a row containing some data? Will any column
(I'm thinking either A or B) always have data in them when the row contains
data?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top