Streamlining Macro Created by Macros Recorder

September 27, 2009 by vba excel
Filed under: Excel Tips 
Sponsor

Excel Tips Streamlining Macro Created by Macros Recorder [Q]

I used the macro recorder in Excel to create a nice macro to reorganize some raw data into a format more useful for Excel to work with. In moving the data around, at one point I selected a range (J8:R8) and copied/pasted the formulas in it down to the bottom of the worksheet, then copied that entire range and pasted values. That portion of the code (from the recorder) looked like this:

Range(”J8:R8″).Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks :=False, Transpose:=False

I’d really like to knock this down to just a couple of lines, maybe three at
most. Can anyone help out? Thanks.

Excel Tips Streamlining Macro Created by Macros Recorder [A]

Your “three” line excel tips is below, along with a separate approach. (You’ll
likely get a number of answers that all have a slightly different way to
achieve your results).

Sub ThreeLines()
Range(”J8:R8″).Copy Range(Range(”J8:R8″), Range(”J8:R8″).End(xlDown))
Range(Range(”J8:R8″), Range(”J8:R8″).End(xlDown)).Copy
Range(Range(”J8:R8″), Range(”J8:R8″).End(xlDown)).PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub

Sub SeparateApproach()
Dim Rng As Range
Set Rng = Range(”J8:R8″)
Set Rng = Range(Rng, Rng.End(xlDown))
Rng.FillDown
Rng.Copy
Rng.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End Sub

  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google
  • E-mail this story to a friend!
  • Live
  • MisterWong
  • Propeller
  • StumbleUpon
  • Technorati
  • TwitThis
  • YahooMyWeb
  • Print this article!

Rate This Tips:

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...


Incoming excel search terms

,how to write macro recorder for excel,macro recorder tips,vba macro transferring data between workbooks,excel created by,vba transpose copy,copy paste excel macro transfer workbook,data streamlining in excel,excel filldown selection macro,excel formula selection copy,excel how to limit filldown,excel macro copy and paste to another worksheet by criteria,excel macro copy data between workbooks,excel macro copy range image,excel macro excel xldown,excel macro fill down,excel macro if formula,excel macro recoder limit,excel macro recorder tips,excel macro recording tips,excel macro to copy multiple worksheets workbooks,excel macro trendline,excel macro tricks,excel transpose macro in different workbooks,excel vba code streamlining sheet change,excel vba copy between spreadsheets,excel vba copy paste tricks,excel vba paste transpose,excel vba sending data between macros,excel vba tips and tricks,excel vba xldown,excel vba xlpastevalues,fill down excel macro,formulas excel macro recorder,how are macros created,how does excel macro recorder determine cell range,how to specify filldown limit in excel macros,how to transpose date from one workbook to another macro,macro copy range down,macro for transposing data excel,macro recorder goes to each worsheet,macro recorder to transfer data from a row to another worksheet excel,macro to paste range,macros for excel to copy all active worksheets and copy and paste to a new sheet,microsoft excel vba selection copy,paste to another worksheet excel,pastespecial paste:=xlpastevalues,rng recorder,streamline excel macro,streamlining excel macros



Related Excel Tips

Comments

Have another excel answer or questions for this problem ?
Feel free to post it here..