Please help with the following issue that i have
I have 1 visible sheet which is named ECOSHEET 1 , ECOSHEET 1 has two button in it . ( i will explain what those do )
I also have 1 hidden sheet that i named it ECOSHEET X
those two buttons in the first sheet does the following
button # 1 when i click it taken ECOSHEET X and copies it to ECOSHEET X2 ( But this time it is visible ) , i can click as much as i want to add more pages like ECOSHEET X2, ECOSHEET X3, etc...
Button # 2 when i click it takes all the sheets and renames them the way i want like ECOSHEET 1, ECOSHEET2, ECOSHEET 3, etc... it also fixed the order if they are moved around
What is my problem ???
The code below is the code i use for button #2 but the problem is when i click on it it considers the hidden sheet when it reorders them and when it renames them , so this is happening in the tabs ECOSHEET1, ECOSHEET3,ECOSHEET4, etc............ The problem is it considers the hidden sheet and it renames the hidden sheet to ECOSHEET 2 which is hidden, i need to take that out , so it ignores my hidden sheet (since i use the hidden sheet as a sample to get a copy , can someone let me know what modification i need to do to fix this please ?????
I am new to VBA coding and i am not sure how to do this. Please help
Sub Button342_Click()
Dim r As Integer
bsheetexists = False
For i = 2 To Sheets.Count
If Sheets(i).Name = "ECOSHEET" & i Then bsheetexists = True
If bsheetexists = False Then
End If
For r = 2 To Sheets.Count
On Error Resume Next
Sheets(r).Name = "ECOSHEET" & " " & r
Next r
Next i
Dim k As Integer
Dim t As Integer
For k = 1 To Sheets.Count
For t = 1 To Sheets.Count - 1
If UCase$(Sheets(t).Name) > UCase$(Sheets(t + 1).Name) Then
Sheets(t).Move After:=Sheets(t + 1)
End If
Next t
Next k
50 End Sub
I have 1 visible sheet which is named ECOSHEET 1 , ECOSHEET 1 has two button in it . ( i will explain what those do )
I also have 1 hidden sheet that i named it ECOSHEET X
those two buttons in the first sheet does the following
button # 1 when i click it taken ECOSHEET X and copies it to ECOSHEET X2 ( But this time it is visible ) , i can click as much as i want to add more pages like ECOSHEET X2, ECOSHEET X3, etc...
Button # 2 when i click it takes all the sheets and renames them the way i want like ECOSHEET 1, ECOSHEET2, ECOSHEET 3, etc... it also fixed the order if they are moved around
What is my problem ???
The code below is the code i use for button #2 but the problem is when i click on it it considers the hidden sheet when it reorders them and when it renames them , so this is happening in the tabs ECOSHEET1, ECOSHEET3,ECOSHEET4, etc............ The problem is it considers the hidden sheet and it renames the hidden sheet to ECOSHEET 2 which is hidden, i need to take that out , so it ignores my hidden sheet (since i use the hidden sheet as a sample to get a copy , can someone let me know what modification i need to do to fix this please ?????
I am new to VBA coding and i am not sure how to do this. Please help
Sub Button342_Click()
Dim r As Integer
bsheetexists = False
For i = 2 To Sheets.Count
If Sheets(i).Name = "ECOSHEET" & i Then bsheetexists = True
If bsheetexists = False Then
End If
For r = 2 To Sheets.Count
On Error Resume Next
Sheets(r).Name = "ECOSHEET" & " " & r
Next r
Next i
Dim k As Integer
Dim t As Integer
For k = 1 To Sheets.Count
For t = 1 To Sheets.Count - 1
If UCase$(Sheets(t).Name) > UCase$(Sheets(t + 1).Name) Then
Sheets(t).Move After:=Sheets(t + 1)
End If
Next t
Next k
50 End Sub