View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Y[_3_] Dave Y[_3_] is offline
external usenet poster
 
Posts: 13
Default Macro Help to Copy to Last Cell

Hello,

I created a macro using the recorder that is used to copy
a formula down to the last cell in a worksheet. Below is
the code for this macro:
Sub CopyFormula()
'
' CopyFormula Macro
' Macro recorded 6/30/2004 by dy
'
Range("G2").Select
Selection.Copy
Range("E3:G3").Select
Range("G3").Activate
Range(Selection, Selection.End(xlDown)).Select
Range("G3:G215").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub

The problem is in the code statement of Range("G3:G215");
this was created when I recorded the macro which worked
today because G215 is currently the last cell. Tomorrow
when I paste new data into the worksheet there will be
more data which will obviously create the need to use more
rows beyond G215. My macro, as it stands, will only copy
down to G215 unless I manually change the range in the
code. How can I change this recorded code to know to copy
down to the current last cell automatically (dynamically)
so that the formula will get copied to the the last needed
cell? Any help will be greatly appreciated. Thank you.
Dave Y