Hello,
I have a drop down menu (in cell E6) with the following options: empty, apple, banana, pineapple. The menu is placed in a sheet called "Start".
It is already assigned that when the option is empty number 1 is assigned, for apples is 2, for bananas is 3 and for pineapple is 4. It takes these numbers from column F
In order to understand what option is chosen I have this codeline: Choice = Range("F" + Number).Value
where number is 6 (i need to state it like this because there are more drop down menus bellow E6)
Each option is unhiding a sheet that its used by the user, in order to enter some data. The sheet is called "Fruit:" + the name of the chosen fruit (Fruit:apple, Fruit:banana, Fruitineapple)
I would like to rename the "Fruit:x" sheet and make it hidden again, if the user decides to chose another option from the drop down menu, after he has already made a choice.
Number = 6
Dim Choice As Integer
Dim i As Integer
Choice = Range("F" + Number).Value
If Choice = 1 Then 'When you choose the empty cell'
If IsEmpty(Sheets("Start").Cells(Number, 7).Value) Then 'This is when there is not an existing tab'
'do nothing
Exit Sub
ElseIf Not IsEmpty(Sheets("Start").Cells(Number, 7).Value) Then 'There is an existing tab'
Msg = "There is already a choice made. Would you like to overwrite it?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbYes Then
If i = 2 Then
Ark11.Name = "Fruit:apple"
Sheets(Fruit:apple).Activate
ActiveWorkbook.Sheets(Fruit:apple).Visible = False 'Makes hidden sheet hidden
End If
If i = 3 Then
.
.
.
End If
If i = 4 Then
.
.
.
End If
Sheets("Start").Activate 'Return to front page
Sheets("Start").Range("G" + Number).ClearContents 'Deletes the name given for "anvendelse 1"
Exit Sub
ElseIf Ans = vbNo Then
Exit Sub
End If
End If
End If
If Choice = 2 Then 'When you choose apple'
.
.
.
.
End If
If Choice = 3 Then 'When you choose banana'
.
.
.
.
End If
If Choice = 4 Then 'When you choose pineapple'
.
.
.
.
End If
i = Choice
End If
End Sub
My problem is that the code doesnt not understand the i I have set. So it doesnt rename of hide the sheet "Fruit:x" when I make a new choice.
I placed the i = Choice in the bottom, so it can save the previous choice, and use it in case the user tries to overwrite it.
Is there any solution to this?
Thanks in advance!
I have a drop down menu (in cell E6) with the following options: empty, apple, banana, pineapple. The menu is placed in a sheet called "Start".
It is already assigned that when the option is empty number 1 is assigned, for apples is 2, for bananas is 3 and for pineapple is 4. It takes these numbers from column F
In order to understand what option is chosen I have this codeline: Choice = Range("F" + Number).Value
where number is 6 (i need to state it like this because there are more drop down menus bellow E6)
Each option is unhiding a sheet that its used by the user, in order to enter some data. The sheet is called "Fruit:" + the name of the chosen fruit (Fruit:apple, Fruit:banana, Fruitineapple)
I would like to rename the "Fruit:x" sheet and make it hidden again, if the user decides to chose another option from the drop down menu, after he has already made a choice.
Number = 6
Dim Choice As Integer
Dim i As Integer
Choice = Range("F" + Number).Value
If Choice = 1 Then 'When you choose the empty cell'
If IsEmpty(Sheets("Start").Cells(Number, 7).Value) Then 'This is when there is not an existing tab'
'do nothing
Exit Sub
ElseIf Not IsEmpty(Sheets("Start").Cells(Number, 7).Value) Then 'There is an existing tab'
Msg = "There is already a choice made. Would you like to overwrite it?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbYes Then
If i = 2 Then
Ark11.Name = "Fruit:apple"
Sheets(Fruit:apple).Activate
ActiveWorkbook.Sheets(Fruit:apple).Visible = False 'Makes hidden sheet hidden
End If
If i = 3 Then
.
.
.
End If
If i = 4 Then
.
.
.
End If
Sheets("Start").Activate 'Return to front page
Sheets("Start").Range("G" + Number).ClearContents 'Deletes the name given for "anvendelse 1"
Exit Sub
ElseIf Ans = vbNo Then
Exit Sub
End If
End If
End If
If Choice = 2 Then 'When you choose apple'
.
.
.
.
End If
If Choice = 3 Then 'When you choose banana'
.
.
.
.
End If
If Choice = 4 Then 'When you choose pineapple'
.
.
.
.
End If
i = Choice
End If
End Sub
My problem is that the code doesnt not understand the i I have set. So it doesnt rename of hide the sheet "Fruit:x" when I make a new choice.
I placed the i = Choice in the bottom, so it can save the previous choice, and use it in case the user tries to overwrite it.
Is there any solution to this?
Thanks in advance!