Results 1 to 2 of 2

Macro relative references

Threaded View

  1. #1
    Registered User
    Join Date
    10-26-2010
    Location
    Quito, Ecuador
    MS-Off Ver
    Excel 2003
    Posts
    1

    Macro relative references

    I'm attempting create a macro that will add a new line below the line in which the user is, copies all data and formulas from the line above, except for columns G and H. Ends in Column G, ready for editing. I came up the macro below, which does what I want, if you are in row 3, but how do I generalize it.

    Another way to ask the question, how do I change the reference
    Rows("4:4").Select
    to something that means select the row below the one I'm in. e.g.
    Rows("the-one-I'm-in+1").Select

    Sub AddSecondProduct()
    '
    ' AddSecondProduct Macro
    
    '
        Rows("4:4").Select
        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        Rows("3:3").Select
        Selection.Copy
        Rows("4:4").Select
        ActiveSheet.Paste
        Range("G4:H4").Select
        Application.CutCopyMode = False
        Selection.ClearContents
        Range("G4").Select
    End Sub
    Any help appreciated.
    JensPeter
    Last edited by davesexcel; 10-27-2010 at 12:03 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1