Dear all,
I hope you are all well.
I have a ComboBox Form Control in one sheet. The combobox drop down list contains the name of all sheets available. Under the combobox, I have a commandbutton so when a user selects the sheet name from the ComboBox form control and clicks the CommandButton, a range from sheet1 will be copied to the selected sheet.
I have changed the form control name to "MonthDropDown".
Here's the code I am using:
The problem I am facing is an 'Run-Time error 9' - Subscript out of range on the range outlined in red.![]()
Private Sub CommandButton1_Click() Dim sname As String If Sheets("Sheet1").Shapes("MonthDropDown").ControlFormat = "" Then MsgBox "Please enter the Sheet number!", vbCritical, "No week selected" Exit Sub End If With Worksheets("Sheet1") sname = .Shapes("MonthDropDown").ControlFormat.Value Sheets(sname).Range("AU19:AU45").Value = Sheets("Sheet1").Range("AU19:AU45").Value End With End Sub
Any ideas on how to Debug this error?
You assistance on this matter will be highly appreciated.
Best regards,
Filipe Oliveira.











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks