View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Automating Autofill Coding Question

Trisha

You could do this without code.

Select column A and F5SpecialBlanksOK

In the active blank cell enter an = sign then point & click on cell above.

Hit CRTL + ENTER to copy down.

When happy with results, copy the column and in place Paste
SpecialValuesOKEsc.

Macro to do the same job.......

Sub Fill_Blanks()
'by Dave Peterson 2004-01-06
'fill blank cells in column with value above
Dim wks As Worksheet
Dim Rng As Range
Dim LastRow As Long
Dim Col As Long

Set wks = ActiveSheet
With wks
Col = ActiveCell.Column
'or
'col = .range("b1").column

Set Rng = .UsedRange 'try to reset the lastcell
LastRow = .Cells.SpecialCells(xlCellTypeLastCell).Row
Set Rng = Nothing
On Error Resume Next
Set Rng = .Range(.Cells(2, Col), .Cells(LastRow, Col)) _
.Cells.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0

If Rng Is Nothing Then
MsgBox "No blanks found"
Exit Sub
Else
Rng.FormulaR1C1 = "=R[-1]C"
End If

'replace formulas with values
With .Cells(1, Col).EntireColumn
.Value = .Value
End With

End With

End Sub


Gord Dibben Excel MVP


On Mon, 10 Jan 2005 14:09:05 -0800, "TrishaB"
wrote:

Using Excel 2000.

Situation: Importing a text file where column a contains part number,
columns b, c, and d contain information relating to column a. Column a's
value is only listed once for many values in columns b, c, and d.

Goal: Automate autofilling column a's value until that value changes. So,
if cell a1's first value is 12345 with 4 blank cells below it, we need to
autofill cells a2:a5 with 12345, then skip a6 and copy its value to the empty
cells beneath it until that value changes.

The number of cells vary between values.

Any help in accomplishing this would be greatly appreciated.

Trisha