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,excel macro xlpastevalues,excel vba paste:=xlpastevalues,excel vba xlpastevalues,macro created,macro created by,streamline excel macro,streamlining excel vba,vba transpose copy,who created the recorder,clearing cells at the end of a macro recording,copy data to excel macro recorder,copy paste excel macro transfer workbook,copy paste restriction in excel,copy range xldown macro use form,data streamlining in excel,different macros that can be created in excel?,excel end(xldown),excel filldown selection macro,excel filldown vba,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 copy selection to end,excel macro excel xldown,excel macro fill down,excel macro filldown,excel macro if formula,excel macro multiple xldown,excel macro paste limit,excel macro recoder limit,excel macro record tips,excel macro recorder tips,excel macro recording tips,excel macro selection copy,excel macro selection xldown,excel macro to copy multiple worksheets workbooks,excel macro trendline,excel macro tricks,excel macros created,excel macros filldown,excel streamline macro,excel transpose macro,excel transpose macro in different workbooks



Related Excel Tips

Comments

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