+ Reply to Thread
Results 1 to 3 of 3

Copying cells

  1. #1
    Registered User
    Join Date
    12-22-2004
    Posts
    18

    Copying cells

    I'm still learning this stuff, so this please bear with me.


    What I'm trying to do. Copy cell E2 and paste the value in E3, then copy E4 paste into E5 and so on through copy E399 and paste into e410.

    Other and selection.copy then selection.paste

    I need to keep this in VBA since the worksheet gets cleared from time to time and the formulas in the cells get erased.


    What's the easy way in VBA

    Thanks in advance!

    Buddy

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello BuddyB,

    The code below with loop through E2 to E398 copying E2 to E3, E4, to E5, etc. up to E398.
    _________________________________________________________________

    Public Sub MyMacro()

    'Start with a loop through the range and skip one cell each time.

    For I = 2 To 398 Step 2

    'Move the Even Cell contents to Odd Cell on the Worksheet

    With Activesheet
    .Cells(I + 1, 5).Value = .Cells(I, 5).Value
    End With


    'Test Loop if Loop is finished
    Next I

    'Copy E399 into E410

    With Activesheet
    .Range("E410").Value = .Range("E399").Value
    End With


    End Sub
    _________________________________________________________________

    Copy this code and insert it into a VBA Module so you can run it as a macro.


    This should get you going,
    Leith Ross

  3. #3
    Registered User
    Join Date
    12-22-2004
    Posts
    18

    Copying cells

    Leith


    Thanks for the help....works like a charm

    Buddy

+ 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