Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Fill down function

From my long experience I'd recommend the following wooden method, which
works with the selection - it is obviously most reliable. Though it may be
easily re-built to the UsedRange or so.

PB

Sub CopyInSelect()

'Macro fills up the empty cells in the selection in such a way that it
'copies each non-empty one, beginning with the upper left corner, into the
'following ones, until it hits the next non-empty. Then the same process
'repeats again. If the number of columns in the selection is
'greater or equal to the number of rows, the copying runs from up to down,
'and vice versa from left to right.
'Petr Bezucha, 2002

Dim I As Long, R1 As Long, R2 As Long
Dim J As Long, C1 As Long, C2 As Long
With Selection
R1 = .Row
R2 = .Rows.Count
C1 = .Column
C2 = .Columns.Count
End With
S = ""
If R2 < C2 Then
For I = R1 To R2
For J = C1 To C2
GoSub Action
Next J
Next I
Else
For J = C1 To C1 + C2 - 1
For I = R1 To R1 + R2 - 1
GoSub Action
Next I
Next J
End If
Exit Sub
Action:
Set C = Cells(I, J)
If IsEmpty(C) Then
C.Value = S
Else
S = C.Value
End If
Return
End Sub

--
Petr Bezucha


"ambr711" wrote:

I want Excel to determine if a cell is blank, if yes then copy the cell
above, if no then move to the next cell until another blank cell is found and
then copy the cell directly above

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
Fill function oic3120 New Users to Excel 0 September 21st 11 03:52 PM
Fill color with if function maz Excel Worksheet Functions 3 July 31st 08 11:30 PM
Fill function Geoffric Excel Worksheet Functions 3 December 18th 07 09:51 AM
Fill Function to next Column shital shah Excel Worksheet Functions 0 August 16th 06 02:53 PM
I have a list of data, fill in the gaps. FILL function won't work Triv Excel Discussion (Misc queries) 1 September 17th 05 02:33 PM


All times are GMT +1. The time now is 07:04 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"