Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Oct 2003
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help Modifying Macro (Excel 2003)

    I have a macro that I would like to modify:

    Sub CopyMeDownv2()
    Dim i As Integer
    For i = 1 To Range("A65536").End(xlUp).Row - 1 Step 2
    Range("A" & i & ":" & "I" & i).Copy Destination:=Range("A" & (i + 1))
    Next i
    End Sub

    What I need to do is very similar except for instead of the range, it's one cell G3.
    I have tried to figure it out on my own but I can't get it to work. Sorry if this seems trivial but I don't really understand VBA at all.

    Thank you,
    Aluis

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help Modifying Macro (Excel 2003)

    I am not sure that I understand what you are asking, but if you want to copy cell G3 to G4, then the following should do what you want.

    <code>
    Sub CopyMeDownv2()
    Range("G3").Copy Destination:=Range("G4")
    End Sub
    </code>
    Legare Coleman

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Help Modifying Macro (Excel 2003)

    You might want to check out <post:=320,321>post 320,321</post:> which has online info about VBA you may find useful.

    For learning some of the basics of the coding, I highly recommend doing some simple things with the macro recorder running and then looking at the code it produces.

    Steve

  4. #4
    Star Lounger
    Join Date
    Oct 2003
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help Modifying Macro (Excel 2003)

    Actually what I wanted to do was copy the value in G3 to very other cell G5,G7,G9,G11 etc for a selected range (range size will vary).

    Thank you.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help Modifying Macro (Excel 2003)

    Will the selected range always be part of column G? Will it always start at G3?

  6. #6
    Star Lounger
    Join Date
    Oct 2003
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help Modifying Macro (Excel 2003)

    Hi Hans,

    Yes the copy to range will always be a part of column G and no it will not always start at G3.

    Thank you

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Help Modifying Macro (Excel 2003)

    Does this do what you want?

    Sub CopyMeDownv2()
    Dim i As Long
    For i = 1 To Selection.Rows.Count Step 2
    Selection.Cells(i, 1) = Range("G3")
    Next i
    End Sub

  8. #8
    Star Lounger
    Join Date
    Oct 2003
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Help Modifying Macro (Excel 2003)

    Yes Hans. I am indebted to you once again.

    Cheers!

Posting Permissions

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