View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default Automating Autofill Coding Question

One way:

Option Explicit
Sub Fill_Blanks2()

Dim wks As Worksheet
Dim Rng As Range
Dim LastRow As Long
Dim Col As Long

Set wks = ActiveSheet
With wks
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, "A"), .Cells(LastRow, "C")) _
.Cells.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0

If Rng Is Nothing Then
MsgBox "No blanks found"
Exit Sub
Else
Rng.FormulaR1C1 = "=R[-1]C"
With Intersect(Rng.EntireColumn, .UsedRange)
.Value = .Value 'do you want them converted to values?
End With
End If
End With

End Sub

I find that it's easier to do this manually--rather than finding the macro and
then running it. (Unless if it's part of a larger mechanized process)

I'd select the range I want "A2:C (lastrow)"
then edit|goto special|check Blanks
hit the equal sign, then hit up arrow (without looking at the screen)
then hitting ctrl-enter (to fill those empty cells)

Then select column A:C and edit|copy, edit|pastespecial|Values (if necessary).

I think it's quicker and it allows me to do Undo.

wrote:

Gord Dibben wrote:

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

Sub Fill_Blanks()
'by Dave Peterson 2004-01-06
'fill blank cells in column with value above


This macro is very helpful!

How can it be modified to perform the same action on columns B and C
(in addition to column A?)

Thanks in advance!,

- Kobi


--

Dave Peterson