+ Reply to Thread
Results 1 to 3 of 3

Simple Copy and Paste

  1. #1
    Michael
    Guest

    Simple Copy and Paste

    Trying to use the following to simply copy the active cell contents to the
    next column over and for the next 20 rows. Getting late. Why is this
    ignoring the column Offset?
    Thanks.
    >>>>


    Sub Macro2()
    '
    ' Macro2 Macro
    ' Macro recorded 3/6/2005 by Michael
    '
    ' Keyboard Shortcut: Ctrl+z
    ActiveCell.Copy
    Dim MyArray(1 To 20) As Variant
    For i = 1 To 20
    X = MyArray(i)
    ActiveCell.Offset(1, X).Select
    ActiveSheet.Paste
    Next i
    End Sub

    --
    WWW

  2. #2
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Because MyArray is empty.
    You are not setting any values to MyArray.

    - Mangesh

  3. #3
    Yogendra
    Guest

    Re: Simple Copy and Paste

    Not sure exactly what you were trying to achieve, but the problem was
    you did not
    feed values to your array

    Sub Macro2()
    ActiveCell.Copy
    Dim MyArray(1 To 20) As Variant
    For v = 1 To 20
    MyArray(v) = v
    Next v
    For i = 1 To 20
    X = MyArray(i)
    ActiveCell.Offset(1, X).Select
    ActiveSheet.Paste
    Next i
    End Sub

    But i would say, why use array, if the array value and array position
    is identical?
    look at code below.
    Sub Macro_Mine()
    ActiveCell.Copy
    For i = 1 To 20
    ActiveCell.Offset(1, i).Select
    ActiveSheet.Paste
    Next i
    End Sub


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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