Hi,
I've written a short macro that works just fine when I run it from the VB editor. However when I try to tie the code to a command button it doesn't work anymore. This is the code I've written:
Sub CreatePosWorksheet()
Dim x As String
x = Mid(Range("A5").Value, 11, 10)
Sheets("Dummy Pos").Copy Before:=Sheets("ränta")
Sheets("Dummy Pos (2)").Name = "Positions " & x
End Sub
When I try to run the macro by pressing the command button the following error message pops up: Copy method of Worksheet class failed.
Does anyone know what the problem might be?
I've written a short macro that works just fine when I run it from the VB editor. However when I try to tie the code to a command button it doesn't work anymore. This is the code I've written:
Sub CreatePosWorksheet()
Dim x As String
x = Mid(Range("A5").Value, 11, 10)
Sheets("Dummy Pos").Copy Before:=Sheets("ränta")
Sheets("Dummy Pos (2)").Name = "Positions " & x
End Sub
When I try to run the macro by pressing the command button the following error message pops up: Copy method of Worksheet class failed.
Does anyone know what the problem might be?