maybe i'll get lucky again

  • Thread starter Thread starter Kent Eilers
  • Start date Start date
K

Kent Eilers

Could anyone point out where my formula copying is going bad on me? or is
there a much simpler way to accomplish this?

Thanks very much

)

================================================

Private Sub copyFormulas(aws As Worksheet, aRow As Integer)
'move UP one row, move across range, if cell is a formula copy to aRow

Dim rCurrent As Range

On Error GoTo errhdl

Set rCurrent = aws.Range(gcstrNameColumn & (aRow - 1))

Do Until rCurrent.Value = ""
If rCurrent.HasFormula Then
'neither of these work...
'>>>>>=========================
rCurrent.Copy (rCurrent.Offset(-1, 0))
'rCurrent.Offset(-1, 0).Formula = rCurrent.Formula
'==========================<<<<
End If
'next column
Set rCurrent = rCurrent.Offset(0, 1)
Debug.Print rCurrent.Cells(1).Column
Loop
Exit Sub

errhdl:
Stop

End Sub
 
This
rCurrent.Copy (rCurrent.Offset(-1, 0))

should not have parentheses.

rCurrent.Copy rCurrent.Offset(-1, 0)

The second should work.

Regards,
Tom Ogilvy
 
Kent,
Does this return a valid range object ?
Set rCurrent = aws.Range(gcstrNameColumn & (aRow - 1))

Which line errors ?

NickHK
 
I believe so...


Nick Cranham said:
Kent,
Does this return a valid range object ?
Set rCurrent = aws.Range(gcstrNameColumn & (aRow - 1))

Which line errors ?

NickHK
 
yep - just ran through it again.

)

Nick Cranham said:
Kent,
Does this return a valid range object ?
Set rCurrent = aws.Range(gcstrNameColumn & (aRow - 1))

Which line errors ?

NickHK
 
thanks - it worked ))

Tom Ogilvy said:
This
rCurrent.Copy (rCurrent.Offset(-1, 0))

should not have parentheses.

rCurrent.Copy rCurrent.Offset(-1, 0)

The second should work.

Regards,
Tom Ogilvy
 
Back
Top