Hi,
When I changed from Excel2003 to Excel2010 some of my Macros stopped to work. I need a macro that autmatically add a number of worksheet in the end of the workbook, but somethings seems to be wrong in the "Sheet.Add ...." command line, and I do not find the problem, can anyone help me to solve this problem?
Thanks in advance!
Code:
Private Sub CommandButton1_Click()
Dim wb As Workbook
Dim x As Integer
Dim myPath As String
Dim SheetCoreName As String
Dim numtimes As Integer
myPath = ActiveWorkbook.Path
Worksheets("TVS-ber").Copy
Set wb = ActiveWorkbook
wb.SaveAs (myPath & "\TVS-ber.xltm"), FileFormat:=53
' 52 = xlOpenXMLWorkbookMacroEnabled = xlsm (with macro's in 2007-2010)
wb.Close
x = Worksheets("Geometri").Range("A3")
For numtimes = 1 To x
Sheets.Add after:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count), Type:=(myPath & "\TVS-ber.xltm")
ActiveSheet.Range("R2") = numtimes + 6
SheetCoreName = "x = "
ActiveSheet.Name = SheetCoreName & ActiveSheet.Range("S13")
Next
End Sub
When I changed from Excel2003 to Excel2010 some of my Macros stopped to work. I need a macro that autmatically add a number of worksheet in the end of the workbook, but somethings seems to be wrong in the "Sheet.Add ...." command line, and I do not find the problem, can anyone help me to solve this problem?
Thanks in advance!
Code:
Private Sub CommandButton1_Click()
Dim wb As Workbook
Dim x As Integer
Dim myPath As String
Dim SheetCoreName As String
Dim numtimes As Integer
myPath = ActiveWorkbook.Path
Worksheets("TVS-ber").Copy
Set wb = ActiveWorkbook
wb.SaveAs (myPath & "\TVS-ber.xltm"), FileFormat:=53
' 52 = xlOpenXMLWorkbookMacroEnabled = xlsm (with macro's in 2007-2010)
wb.Close
x = Worksheets("Geometri").Range("A3")
For numtimes = 1 To x
Sheets.Add after:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count), Type:=(myPath & "\TVS-ber.xltm")
ActiveSheet.Range("R2") = numtimes + 6
SheetCoreName = "x = "
ActiveSheet.Name = SheetCoreName & ActiveSheet.Range("S13")
Next
End Sub