johnsending
New Member
- Joined
- Jul 25, 2018
- Messages
- 17
Hello everyone,
I'm encounter an issue with Excel when using the formula below. I have a button with the VBA code on it and it works perfectly but if my list consists of more than 15 entries, Excel crashes when trying to auto-create the tabs after the 15th entry. Is there any way to modify the code to only do 15 at a time (1st - 15 entries, then next set of 15 entries, then the next 15...) when pressed repeatedly? I'm also open to other corrections since I can only press the button once before getting an error. I'm not well-versed on VBA.
Sub CreateDeviceSheets()
Dim wsNew As Worksheet
Dim strName As String
Dim I As Long
With Sheets("Switch-List")
For I = 2 To .Range("A" & Rows.Count).End(xlUp).Row
strName = .Range("A" & I).Value
Set wsNew = Sheets(.Range("B" & I).Value)
With wsNew
.Visible = xlSheetVisible
.Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = strName
.Visible = xlSheetHidden
End With
ActiveSheet.Name = strName
Next I
End With
End Sub
Thanks,
John
I'm encounter an issue with Excel when using the formula below. I have a button with the VBA code on it and it works perfectly but if my list consists of more than 15 entries, Excel crashes when trying to auto-create the tabs after the 15th entry. Is there any way to modify the code to only do 15 at a time (1st - 15 entries, then next set of 15 entries, then the next 15...) when pressed repeatedly? I'm also open to other corrections since I can only press the button once before getting an error. I'm not well-versed on VBA.
Sub CreateDeviceSheets()
Dim wsNew As Worksheet
Dim strName As String
Dim I As Long
With Sheets("Switch-List")
For I = 2 To .Range("A" & Rows.Count).End(xlUp).Row
strName = .Range("A" & I).Value
Set wsNew = Sheets(.Range("B" & I).Value)
With wsNew
.Visible = xlSheetVisible
.Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = strName
.Visible = xlSheetHidden
End With
ActiveSheet.Name = strName
Next I
End With
End Sub
Thanks,
John