Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy value and fill blank spaces below it until new value is encountered?

Hi,

I have a column of data as follows in excel, with a value, followed by
multiple blank cells, then a new value, and so forth:

_Column_A:_

1GT34Z
<blank
<blank
2FR56T
<blank
<blank
<blank
5VG56R
<blank
etc....

How do I create a macro that begins at the top of the column A, and
then proceeds vertically down cell by cell, checking whether a value is
present? If there is a value present, it will move on, however, if
there is NOT a value present, it will check the cell directly above it
and copy that value into it, as well as every consecutive blank row
following it, until a cell with a different value is encountered.
Hence, when the macro is complete, all the rows that were originally
<blank will have a value present in it based on whatever value it
followed. Then proceed to column B and repeat.

Thanks in advance!
drod


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy value and fill blank spaces below it until new value is encountered?

Is there a limit to how many rows it will copy down or do you expect the
macro to fill down to the last row in excel 65536 rows


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy value and fill blank spaces below it until new value is encountered?

I only need it to go down to the end of the values of the data, not the
entire end of the spreadsheet. I guess in this instance, I could enter
the value "end" after the final value in the column and then ask the
macro to stop and move to the next row when it encounters "end".

Or is there a more effecient way?
Thanks.


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Copy value and fill blank spaces below it until new value is encountered?

drod

Sub Fill_Blanks()
Dim myRange As Range
Set myRange = Selection
On Error GoTo stopnow
If myRange.Cells.Count = 1 Then
MsgBox "Select a range first."
Else
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.FormulaR1C1 = "=R[-1]C"
End If
stopnow:
End Sub

You can select multiple columns before running.

Gord Dibben Excel MVP


On Wed, 7 Jan 2004 15:18:50 -0600, drod
wrote:

Hi,

I have a column of data as follows in excel, with a value, followed by
multiple blank cells, then a new value, and so forth:

_Column_A:_

1GT34Z
<blank
<blank
2FR56T
<blank
<blank
<blank
5VG56R
<blank
etc....

How do I create a macro that begins at the top of the column A, and
then proceeds vertically down cell by cell, checking whether a value is
present? If there is a value present, it will move on, however, if
there is NOT a value present, it will check the cell directly above it
and copy that value into it, as well as every consecutive blank row
following it, until a cell with a different value is encountered.
Hence, when the macro is complete, all the rows that were originally
<blank will have a value present in it based on whatever value it
followed. Then proceed to column B and repeat.

Thanks in advance!
drod


---
Message posted from http://www.ExcelForum.com/


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy value and fill blank spaces below it until new value is encountered?

Gord, thanks for the help, its working great!

dro

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Up until Non-Blank Cell encountered Jim May Excel Discussion (Misc queries) 6 November 28th 07 02:02 PM
How-To fill down blank spaces in outlined table? clydelane Excel Discussion (Misc queries) 2 May 16th 07 11:55 PM
Fill blank cells with spaces [email protected] Excel Worksheet Functions 6 March 22nd 06 09:17 AM
Blank spaces Scurloc Excel Discussion (Misc queries) 4 December 22nd 05 05:08 PM
Copy down - special to fill only the blank cells Mike Excel Discussion (Misc queries) 3 April 18th 05 10:08 PM


All times are GMT +1. The time now is 04:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"