Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default R/T Error 1004

Code is Bombing 4 lines from bottom;
How can I alter to fix?

Sub FillInBlanks()
Dim Rng1 As Range, Rng2 As Range
Dim RngArea As Range
If Selection.Columns.Count 1 Then
MsgBox "You can Only Select 1 Column at a time"
Exit Sub
End If
Set Rng1 = Selection
Set Rng2 = Rng1.SpecialCells(xlCellTypeBlanks)
Rng2.FormulaR1C1 = "=R[-1]C"
With Rng2
.Copy
.PasteSpecial xlPasteValues ' R/T 1004 - CANNOT BE USED ON MULTIPLE
SELECTIONS
End With
Application.CutCopyMode = False
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default R/T Error 1004

Hi Jim,

Try:

'=============
Public Sub FillInBlanks()
Dim Rng1 As Range, Rng2 As Range
Dim RngArea As Range

If Selection.Columns.Count 1 Then
MsgBox "You can Only Select 1 Column at a time"
Exit Sub
End If

Set Rng1 = Selection

On Error Resume Next 'In case no blanks found!
Set Rng2 = Rng1.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0

If Not Rng2 Is Nothing Then
Rng2.FormulaR1C1 = "=R[-1]C"
With Rng1
.Value = .Value
End With
End If
End Sub
'<<=============


---
Regards,
Norman



"Jim May" wrote in message
news:tWQpg.49358$fG3.31811@dukeread09...
Code is Bombing 4 lines from bottom;
How can I alter to fix?

Sub FillInBlanks()
Dim Rng1 As Range, Rng2 As Range
Dim RngArea As Range
If Selection.Columns.Count 1 Then
MsgBox "You can Only Select 1 Column at a time"
Exit Sub
End If
Set Rng1 = Selection
Set Rng2 = Rng1.SpecialCells(xlCellTypeBlanks)
Rng2.FormulaR1C1 = "=R[-1]C"
With Rng2
.Copy
.PasteSpecial xlPasteValues ' R/T 1004 - CANNOT BE USED ON MULTIPLE
SELECTIONS
End With
Application.CutCopyMode = False
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default R/T Error 1004

Norman,
Anytime when returning to my PC after posting a Question AND I see
"Norman Jones" - I know I'm gonna get a good reply +++ learn something
GOOD - Your
Suggested code is perfect - Yeah it's the original Values Rng1 that need
Converting to Values, not having to refer to the Rng2. Thanks Again;
Jim May

"Norman Jones" wrote in message
:

Hi Jim,

Try:

'=============
Public Sub FillInBlanks()
Dim Rng1 As Range, Rng2 As Range
Dim RngArea As Range

If Selection.Columns.Count 1 Then
MsgBox "You can Only Select 1 Column at a time"
Exit Sub
End If

Set Rng1 = Selection

On Error Resume Next 'In case no blanks found!
Set Rng2 = Rng1.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0

If Not Rng2 Is Nothing Then
Rng2.FormulaR1C1 = "=R[-1]C"
With Rng1
.Value = .Value
End With
End If
End Sub
'<<=============


---
Regards,
Norman



"Jim May" wrote in message
news:tWQpg.49358$fG3.31811@dukeread09...

Code is Bombing 4 lines from bottom;
How can I alter to fix?

Sub FillInBlanks()
Dim Rng1 As Range, Rng2 As Range
Dim RngArea As Range
If Selection.Columns.Count 1 Then
MsgBox "You can Only Select 1 Column at a time"
Exit Sub
End If
Set Rng1 = Selection
Set Rng2 = Rng1.SpecialCells(xlCellTypeBlanks)
Rng2.FormulaR1C1 = "=R[-1]C"
With Rng2
.Copy
.PasteSpecial xlPasteValues ' R/T 1004 - CANNOT BE USED ON MULTIPLE
SELECTIONS
End With
Application.CutCopyMode = False
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
Error 1004, Application-definded or object-defined error Mirco Wilhelm[_2_] Excel Programming 9 January 7th 06 04:56 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Run time error 1004 General ODCB Error Kevin Excel Programming 3 February 26th 05 12:51 PM


All times are GMT +1. The time now is 09:43 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"