Thread: Fill cells
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
chrisnsmith chrisnsmith is offline
external usenet poster
 
Posts: 96
Default Fill cells

That worked great Chip, but now I'm sorry to say I need it to work on 4
worksheets. Can you tell me what I need to change?
"Chip Pearson" wrote:

You can use code like

Sub AAA()
Dim FirstLine As Long
Dim N As Long
Dim LastLine As Long
Dim DataColumn As String
Dim WS As Worksheet

FirstLine = 1 '<<< CHANGE AS REQUIRED
DataColumn = "B" '<<< CHANGE AS REQUIRED
Set WS = Worksheets("Sheet1") '<<< CHANGE AS REQUIRED
With WS
LastLine = .Cells(.Rows.Count, DataColumn).End(xlUp).Row
For N = FirstLine To LastLine
If .Cells(N, DataColumn).Value = vbNullString Then
.Cells(N, DataColumn).Value = _
.Cells(N - 1, DataColumn)
End If
Next N
End With

End Sub


Change the lines marked with <<<< to the appropriate values.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Sat, 7 Mar 2009 20:31:00 -0800, chrisnsmith
wrote:

Imagine a worksheet that looks something like this:

cell B6 = WH
B40=WK
B55=WN
B73=WU
B88=WZ

The rows between these have no entries in column B. Is there a way to fill
the cells between the WH and WK with WH, and cells between WK and WN with WK
and so on until all cells are filled.