Results 1 to 10 of 10

Loop to find a cell, then copy offset paste

Threaded View

  1. #9
    Registered User
    Join Date
    01-29-2013
    Location
    Poland
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Loop to find a cell, then copy offset paste

    hello, i need macro to find value in column A(level) (in next column are values too), after find this value, cut all data from this row and move right to defined offset.

    eg line with level:

    0 not move
    1 not move
    2 move right one position all data with this line
    3 move right two position all data with this line
    4 move right three position all data with this line
    5 move right four position all data with this line




    I have to make tree structure

    my macro is:

    Sub Macro1()
     
    Dim x As Range
     
     
    Do
    Set x = Columns(1).Find("2*")
    If x Is Nothing Then Exit Do
    x.Select
    Selection.Cut
    ActiveCell.Offset(0, 1).Select
    ActiveSheet.Paste
    Loop
    
    Do
    Set x = Columns(1).Find("3*")
    If x Is Nothing Then Exit Do
    
    Selection.Cut
    ActiveCell.Offset(0, 2).Select
    ActiveSheet.Paste
    Loop
    
    Do
    Set x = Columns(1).Find("4*")
    If x Is Nothing Then Exit Do
    x.Select
    Selection.Cut
    ActiveCell.Offset(0, 3).Select
    ActiveSheet.Paste
    Loop
    
    Do
    Set x = Columns(1).Find("5*")
    If x Is Nothing Then Exit Do
    x.Select
    Selection.Cut
    ActiveCell.Offset(0, 4).Select
    ActiveSheet.Paste
    Loop
    
    
    
    End Sub
    but move only one cell right (i need all data from line move right to define position)
    please help
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by arlu1201; 01-29-2013 at 08:46 AM.

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