Hi,
I'm very new to VBA and I'm trying to write a code that simply takes the data from one tab and copies it into a new tab then changes the name of the newly created tab to the value of cell C9, I'm sure this is very simple but i can't link the 2 steps and i keep getting error messages!!
Here is the code i have but it doesn't work -
Cells.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
'Change name of tab
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) = "C9" Then
If Len(Trim(Target.Value)) > 0 Then
On Error Resume Next
Me.Name = Target.Value
On Error GoTo 0
End If
End If
End Sub
Any help would be greatly appreciated!
I'm very new to VBA and I'm trying to write a code that simply takes the data from one tab and copies it into a new tab then changes the name of the newly created tab to the value of cell C9, I'm sure this is very simple but i can't link the 2 steps and i keep getting error messages!!
Here is the code i have but it doesn't work -
Cells.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
'Change name of tab
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) = "C9" Then
If Len(Trim(Target.Value)) > 0 Then
On Error Resume Next
Me.Name = Target.Value
On Error GoTo 0
End If
End If
End Sub
Any help would be greatly appreciated!