Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy Formula to Last Needed Cell in Spreadsheet
Hello,
I have recorded a macro that will is supposed to copy a formula from the first cell of a specified column to the last cell that I need the formula to be copied to. When I recorded the macro it put a specific range in the VBA code, below is the code that was created during the record macro process: Sub CopyFormula() ' ' CopyFormula Macro ' Macro recorded 6/18/2004 by dy ' ' Range("G2").Select Application.CutCopyMode = False Selection.Copy Range("E3:G3").Select Range("G3").Activate Range(Selection, Selection.End(xlDown)).Select Range("G3:G204").Select ActiveSheet.Paste Application.CutCopyMode = False End Sub The problem is that my range will get larger each day. So tomorrow when I run My SQL script and then paste the data into the Excel spreadsheet there may be 210 rows and this VBA code will only copy the formula down to row 204 unless I manually edit the code. How can I change this code so that it will automatically know the last row that I need to copy the formula to? Any help for a solution will be greatly appreciated. Thank you. Dave Y |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy Formula to Last Needed Cell in Spreadsheet
Try this...
Range("G2").Copy Range(Selection, Selection.End(xlDown)).Select ActiveSheet.Paste *** Sent via Devdex http://www.devdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I copy a formula from one spreadsheet to another | Excel Discussion (Misc queries) | |||
Excel formula to copy/paste formula needed please. | Excel Discussion (Misc queries) | |||
help needed to write formula for excel spreadsheet | Excel Discussion (Misc queries) | |||
Formula needed for repetative spreadsheet | Excel Worksheet Functions | |||
Copy formula only from one spreadsheet to another | Excel Worksheet Functions |