Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default maybe i'll get lucky again

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

--
kent eilers



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default maybe i'll get lucky again

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 Eilers wrote in message
...
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

--
kent eilers





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default maybe i'll get lucky again

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

Which line errors ?

NickHK


"Kent Eilers" wrote in message
...
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

--
kent eilers





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default maybe i'll get lucky again

I believe so...


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

Which line errors ?

NickHK


"Kent Eilers" wrote in message
...
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

--
kent eilers







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default maybe i'll get lucky again

yep - just ran through it again.

)

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

Which line errors ?

NickHK


"Kent Eilers" wrote in message
...
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

--
kent eilers









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default maybe i'll get lucky again

thanks - it worked ))

"Tom Ogilvy" wrote in message
...
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 Eilers wrote in message
...
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

--
kent eilers







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
4th time lucky? Russell Excel Discussion (Misc queries) 8 December 31st 09 09:55 AM
Counting Days between Accidents (Third time lucky?) aussiegirlone Excel Discussion (Misc queries) 5 December 6th 08 09:33 PM
Lucky Draw aggregate sum over the periods Excel Discussion (Misc queries) 2 November 22nd 06 11:48 AM


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