View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
scorpiorc scorpiorc is offline
external usenet poster
 
Posts: 5
Default Finding blank cells

My column looks like this, I have data in D1, then cells D2:D10 are blank,
then data in D11 and so on. The data is spaced throughout the column
(ie...not always the same # of blank cells between data). Also, the last
cell in the range can vary from week to week. I need to copy the data cell
to all blank cells below it until I get to the next nonblank cell. So if I
have "A" in D1, "B" in D11 and cells D2:D10 are blank, I need to copy "A"
into D2:D10, and then B into D12:D? (however many blank cells are below until
the next cell with data).

I have written something like this to work on a similar worksheet I have
where I have If c = "_"

lr = Cells(Rows.Count, "D").End(xlUp).Row
For Each c In Range("D1:D" & lr)
If c = "" Then c.Value = c.Offset(-1)
Next

but it does not work with blank cells in this worksheet when I change the
statement to be If c = ""
"Dave Peterson" wrote:

This is usually a very bad idea--to make cells look empty by putting a space
character in them. I wouldn't do it.

For Each z In Range("D1:D???")
If z.Value = "" Then
z = " "
End If
Next z

In fact, I'd get rid of those space character cells:

For Each z In Range("D1:D????")
If trim(z.Value) = "" Then
z.value = ""
End If
Next z



scorpiorc wrote:

I have column D that contains both data and blank cells. I need to find a
way to find the blank cells and fill them with a space. I've tried:

For Each z In Range("D1:D")
If z.Value = IsEmpty("D") Then
z = " "
End If
Next z

but get an error. Any ideas how I can do this?


--

Dave Peterson