ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Copying to blank cells (https://www.excelbanter.com/excel-discussion-misc-queries/121634-copying-blank-cells.html)

scorpiorc

Copying to 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 cell that
has data
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

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 changed the
statement to be If c = ""

Any ideas?

Jim Rech

Copying to blank cells
 
Your code works for me. I can only guess that your 'blank cells' are not
truly empty.

--
Jim
"scorpiorc" wrote in message
...
| 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 cell
that
| has data
| 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
|
| 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 changed the
| statement to be If c = ""
|
| Any ideas?



Dave Peterson

Copying to blank cells
 
See your other thread for more responses.

scorpiorc wrote:

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 cell that
has data
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

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 changed the
statement to be If c = ""

Any ideas?


--

Dave Peterson

Gord Dibben

Copying to blank cells
 

See response in your other thread.


Gord Dibben MS Excel MVP

On Wed, 6 Dec 2006 09:20:00 -0800, scorpiorc
wrote:

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 cell that
has data
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

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 changed the
statement to be If c = ""

Any ideas?




All times are GMT +1. The time now is 10:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com