Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 90274

VBA Macro got me stumped

$
0
0

I'm using a macro to make a copy of the active sheet, and rename it to whatever the value of cell 'C2' is. The only problem is, that when it copies the sheet, it somehow removes the form buttons from the top of my worksheet and replaces them with the code =$c$2 in cell 'AF'.

As far as i can see from the VBA code there is nothing that refers to the cell 'AF'. Can anyone tell me why it's doing this ?

Sub Copy_Rename()
    Dim shtName As String
    shtName = ActiveSheet.Name
    ActiveSheet.Copy before:=ActiveSheet
    ActiveSheet.Name = Range("C2").Value
    Sheets(shtName).Activate
End Sub

Viewing all articles
Browse latest Browse all 90274

Trending Articles