How to create New sheets by column with repeated values

Closed
Military1 Posts 1 Registration date Wednesday November 8, 2017 Status Member Last seen November 8, 2017 - Nov 8, 2017 at 01:27 PM
 Blocked Profile - Nov 8, 2017 at 04:21 PM
Hi


Have lines with various tables in rooms. Rooms numbers are in column, but sometimes room have 2 or more tables so room numbers repeats. Code stop with 1004 error when reach same room number.need skip same number.

Sub CreateSheetsFromAList()
Dim MyCell As Range, MyRange As Range

Set MyRange = Sheets("Summary").Range("A10")
Set MyRange = Range(MyRange, MyRange.End(xlDown))

For Each MyCell In MyRange
Sheets.Add After:=Sheets(Sheets.Count) 'creates a new worksheet
Sheets(Sheets.Count).Name = MyCell.Value ' renames the new worksheet
Next MyCell
End Sub

Related:

1 response

Blocked Profile
Nov 8, 2017 at 04:21 PM
OK here is a programming trick: Put msgbox after each variable so the code will display the variable as the system knows it. Then as it loops through each one, you can visually see where it is failing, and either correct the code to work around the erroneous data, or change the data itself, and hope that when the next person enters the data, they don't enter it in the same way. This is called "trapping".

Please understand, we can cut and paste your code, but without the data example, we will not be able to recreate your error!
0