#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Fill Blanks Macro

I have a spreadsheet that has 44,383 rows. I am trying to use the following
macro to fill in the blanks for columns A:D. I am getting a REF error. I
know it is the number of rows because the macro works for spreadsheets that
do not have as many rows. Is there any modification to this code that will
make the macro fill down for 44,383 rows:

Sub FillBlanks2()
Dim Rng As Range
On Error Resume Next
Set Rng = ActiveSheet.UsedRange.Columns("A:D")
With Rng
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
.Copy
.PasteSpecial xlPasteValues
End With
Set Rng = Nothing

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Fill Blanks Macro

Loraine,

IIRC, you cannot have more than 8,000 or so blank cells.

To fix it, you could step down the rows, like this:.

Sub FillBlanks3()
Dim Rng As Range
Dim myRow As Range

On Error Resume Next
Set Rng = ActiveSheet.UsedRange.Columns("A:D")
For Each myRow In Rng.Rows
With myRow
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
.Copy
.PasteSpecial xlPasteValues
End With
Next myRow
Set Rng = Nothing
End Sub


Or, if that is too slow, in bigger chunks:

Sub FillBlanks4()
Dim Rng As Range
Dim i As Long

On Error Resume Next
Set Rng = ActiveSheet.UsedRange.Columns("A:D")
For i = 1 To Rows.Count Step 2000
With Intersect(Rng, Range(i & ":" & i + 2000))
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
.Copy
.PasteSpecial xlPasteValues
End With
Next i
Set Rng = Nothing
End Sub


HTH,
Bernie
MS Excel MVP


"LLoraine" wrote in message
...
I have a spreadsheet that has 44,383 rows. I am trying to use the following
macro to fill in the blanks for columns A:D. I am getting a REF error. I
know it is the number of rows because the macro works for spreadsheets that
do not have as many rows. Is there any modification to this code that will
make the macro fill down for 44,383 rows:

Sub FillBlanks2()
Dim Rng As Range
On Error Resume Next
Set Rng = ActiveSheet.UsedRange.Columns("A:D")
With Rng
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
.Copy
.PasteSpecial xlPasteValues
End With
Set Rng = Nothing

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Fill Blanks Macro

Thank you. I use fillBlanks4 and it worked beautifully.....

"Bernie Deitrick" wrote:

Loraine,

IIRC, you cannot have more than 8,000 or so blank cells.

To fix it, you could step down the rows, like this:.

Sub FillBlanks3()
Dim Rng As Range
Dim myRow As Range

On Error Resume Next
Set Rng = ActiveSheet.UsedRange.Columns("A:D")
For Each myRow In Rng.Rows
With myRow
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
.Copy
.PasteSpecial xlPasteValues
End With
Next myRow
Set Rng = Nothing
End Sub


Or, if that is too slow, in bigger chunks:

Sub FillBlanks4()
Dim Rng As Range
Dim i As Long

On Error Resume Next
Set Rng = ActiveSheet.UsedRange.Columns("A:D")
For i = 1 To Rows.Count Step 2000
With Intersect(Rng, Range(i & ":" & i + 2000))
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
.Copy
.PasteSpecial xlPasteValues
End With
Next i
Set Rng = Nothing
End Sub


HTH,
Bernie
MS Excel MVP


"LLoraine" wrote in message
...
I have a spreadsheet that has 44,383 rows. I am trying to use the following
macro to fill in the blanks for columns A:D. I am getting a REF error. I
know it is the number of rows because the macro works for spreadsheets that
do not have as many rows. Is there any modification to this code that will
make the macro fill down for 44,383 rows:

Sub FillBlanks2()
Dim Rng As Range
On Error Resume Next
Set Rng = ActiveSheet.UsedRange.Columns("A:D")
With Rng
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
.Copy
.PasteSpecial xlPasteValues
End With
Set Rng = Nothing

End Sub




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 in the blanks to smooth my projection curve Statistically Challenged Excel Discussion (Misc queries) 0 November 18th 06 03:40 PM
Fill column blanks from last non-blank cell C. BROWN Excel Discussion (Misc queries) 2 August 28th 06 08:36 PM
How do I fill in pivot table blanks? Lisan Excel Worksheet Functions 1 July 3rd 06 09:11 PM
How do I auto fill long col. filling blanks with last filled cell MBBeginner Excel Discussion (Misc queries) 3 January 15th 06 12:44 AM
How do I auto fill blanks cells immediately below with the same i. leo Excel Discussion (Misc queries) 2 March 16th 05 06:03 PM


All times are GMT +1. The time now is 09:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"