+ Reply to Thread
Results 1 to 5 of 5

code to move cells back to thier original location

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-10-2008
    Location
    UK
    Posts
    220

    code to move cells back to thier original location

    Hi everyone,

    I am using the following code to move certain cells from one sheet to another. The user puts a name in a textbox, it then finds that name on the sheet and copies the correct cells over.

    I would like a code which moves those cells back to thier original location (overwritting the existing). This code will be run after the user has made changes to the contents of the cells..

    So for example...cells are in sheet1...below code pulls them to sheet2..the user makes changes to cell contents....the NEW code moves them back to thier original location, overwritting the existing.

    Private Sub CommandButton3_Click()
     
      Dim DestSheet        As Worksheet
      Dim wsSearchSheet As Worksheet
      Set DestSheet = Worksheets("VIEWER")
      Set wsSearchSheet = Worksheets("MASTER")
      
      Dim sRow       As Long
      Dim sCount     As Long
      sCount = 0
    
        With wsSearchSheet
    
            For sRow = 1 To .Range("A" & Rows.Count).End(xlUp).Row
        
                If .Cells(sRow, "A") Like ViewCompany.TextBox1.Value Then
                    sCount = sCount + 1
                    .Range(.Range("A" & sRow).Resize(1, 7), .Range("A" & sRow).Resize(1, 7).End(xlDown).Offset(0, 0)).Copy _
                        Destination:=DestSheet.Range("A" & Rows.Count).End(xlUp).Offset(0, 0)
                        
                        
                    End If
                        
                        
                       Next sRow
                       
                       End With
                 
        Unload Me
        Sheets("VIEWER").Visible = True
        Sheets("VIEWER").Select
        ViewSingleExit.Show vbModeless
            
    End Sub

    Any ideas?

  2. #2
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: code to move cells back to thier original location

    Hi,

    Can you please post an example workbook? so I can see what your working with.
    Thank You, Mike

    Some Helpful Hints:

    1. New members please read & follow the Forum Rules
    2. Use Code Tags...Place[code]Before the first line and[/code] After the last line.
    3. If you are pleased with a solution mark your post SOLVED.
    4. Thank those who have help you by clicking the scales at the top right of the post.

    Here...

  3. #3
    Forum Contributor
    Join Date
    07-10-2008
    Location
    UK
    Posts
    220

    Re: code to move cells back to thier original location

    thanks for the reply, an example worksheet is attached.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    07-10-2008
    Location
    UK
    Posts
    220

    Re: code to move cells back to thier original location

    Hi Guys,

    any help with this one? please take a look at my example workbook and let me know.

  5. #5
    Forum Contributor
    Join Date
    07-10-2008
    Location
    UK
    Posts
    220

    Re: code to move cells back to thier original location

    bump?

    thanks

+ 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