Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default .Value = .Value - Error

Got a code the runs 91% of the time, but every now and then I get an
error on this particular line....

(This messes with my mojo cause I keep having to stop and re-run it
after I close Excel out)

Sub FillColBlanksA()
Dim wks As Worksheet
Dim Rng As Range
Dim lastrow As Long
Dim col As Long

Set wks = ActiveSheet
With wks
col = .Range("A1").Column

Set Rng = .UsedRange
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

With .Cells(1, col).EntireColumn
.Value = .Value
End With

End With

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default .Value = .Value - Error

Maybe you could try:

With .Cells(1, col).EntireColumn
.copy
.pastespecial paste:=xlpastevalues
End With



"J.W. Aldridge" wrote:

Got a code the runs 91% of the time, but every now and then I get an
error on this particular line....

(This messes with my mojo cause I keep having to stop and re-run it
after I close Excel out)

Sub FillColBlanksA()
Dim wks As Worksheet
Dim Rng As Range
Dim lastrow As Long
Dim col As Long

Set wks = ActiveSheet
With wks
col = .Range("A1").Column

Set Rng = .UsedRange
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

With .Cells(1, col).EntireColumn
.Value = .Value
End With

End With

End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default .Value = .Value - Error

Thanx....

Wurked purfectly!

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
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Form Err.Raise error not trapped by entry procedure error handler [email protected] Excel Programming 1 February 8th 06 10:19 AM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM


All times are GMT +1. The time now is 06:59 AM.

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"