RAJAQ
12/14/2016 - 1:06 PM

Add new sheet and copy paste transpose data from sheetA to sheetB

Add new sheet and copy paste transpose data from sheetA to sheetB

Option Explicit

' CHECK IF DESTINATION SHEET EXISTS - IF NOT , ADD IT.

Sub CheckSht()

Dim mySheetName As String
Dim mySheetNameTest As String

mySheetName = "Transpose"
    
On Error Resume Next

mySheetNameTest = Worksheets(mySheetName).Name
    If Err.Number = 0 Then
        Call SelectRange
    Else
        Err.Clear
        Worksheets.Add.Name = mySheetName
        Call SelectRange
    End If
    
Application.CutCopyMode = False

End Sub

' COPY PASTE DATA ON DESTINATION SHEET

Sub SelectRange()
Dim Rng As Range

    Set Rng = Application.InputBox("Specifiy a range", Type:=8)
        If Rng Is Nothing Then
        Exit Sub
        End If
    Rng.Copy
    
    Sheets("Transpose").Select
    Range("A1048576").End(xlUp).Select
    Selection.Offset(2, 0).Select
    Selection.PasteSpecial Paste:=xlPasteAll, transpose:=True
    
    Sheets("Transpose").Range("A1048576").End(xlUp).Offset(2, 0).Select
        
    Sheets("Copy Fees on This Sheet").Select
            
    Application.CutCopyMode = False
    
End Sub


' DELETE EXISTING DATA TO START THE PROCESS AGAIN WITH NEW DATA

Sub DeleteContents()

Worksheets("Copy Fees on This Sheet").Range("A5:M1000").Delete
Worksheets("Transpose").Cells.Delete

Application.CutCopyMode = False

 Sheets("Copy Fees on This Sheet").Select
 Range("A5").Select
 

End Sub