Results 1 to 2 of 2

Thread: Move table from one sheet to another?
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Feb 2018
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Move table from one sheet to another?

    Hello everyone!

    I am having trouble getting to move an entire table from one sheet to another.

    I found this code from Jerry Sullivan:

    Code:
    Sub ToggleTableHiddenSheet()    Const sHomeSheet = "Sheet1"
        Dim sMoveToSheet As String
        
        With Range("Table1[#All]")
            If .Parent.Name = sHomeSheet Then
                sMoveToSheet = "HideTable"
            Else
                sMoveToSheet = sHomeSheet
            End If
            
            .Cut Destination:= _
                Sheets(sMoveToSheet).Range(.Cells(1).Address)
        End With End Sub
    That is EXACTLY what I need!! (thanks!). However, while it moves the table from A to B, it does not move it from B to A. Is there a way you could help me fix it? I am relatively new at VBA.

    Thank you very much for your help!!

  2. #2
    Board Regular igold's Avatar
    Join Date
    Jul 2014
    Location
    Delray Beach, FL, USA
    Posts
    2,360
    Post Thanks / Like
    Mentioned
    18 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Move table from one sheet to another?

    Is this what you are looking for...

    Code:
    Sub ToggleTableHiddenSheet()
    
    
        Const sHomeSheet = "Sheet1"
        Dim sMoveToSheet As String
        
        With Range("Table1[#All]")
            If .Parent.Name = "sHomeSheet" Then
                sMoveToSheet = "HideTable"
            End If
            If .Parent.Name = "HideTable" Then
                sMoveToSheet = "sHomeSheet"
            End If
            .Cut Destination:= _
                Sheets(sMoveToSheet).Range(.Cells(1).Address)
        End With
        
    End Sub
    ​igold

    I'm a drinker with a coding problem...

    All code is written with Excel 2010 - Please test all code on a backup copy of your data.


Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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