LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Enhancements to Sub FillColBlanks by Dave Peterson

Seeking 2 enhancements to the Sub FillColBlanks() by Dave Peterson (pasted
below for easy reference)

1. Would like the flexibility to "select" either:
(a) a continuous multi-col range with the mouse, say: B3:E3, or
(b) a discontiguous multi-col range say: B3:D3, G3, K3
and then just run the sub once to work on the multi-col range

2. Any text numbers filled down the col(s) should not change to real
numbers. The original format to be retained.

Thanks for insights.

Rgds
Max
--------------- ------
Sub FillColBlanks()
'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
 
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
Dave Peterson Bob Myers Excel Worksheet Functions 2 January 9th 08 03:33 PM
Dave Peterson Rich_Patterson Excel Discussion (Misc queries) 2 January 26th 07 08:56 PM
Dave Peterson joelbeveridge Excel Discussion (Misc queries) 1 August 4th 06 02:55 AM
Dave Peterson Alvin Hansen[_2_] Excel Programming 4 February 12th 05 03:38 AM
To: Dave Peterson PBezucha[_2_] Excel Programming 2 July 14th 04 01:23 AM


All times are GMT +1. The time now is 07:00 PM.

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"