Oh. My. Code. Excel VBA Needs
September 8, 2006 6:14 PM Subscribe
I've created a button in Excel 2002 that runs some VBA when clicked. Works great. I've emailed the spreadsheet home and opened it with Excel 97 and clicking does nothing.
When I run the subroutine from VBA editor, it works fine. So, what gives? Why won't this work in Excel 97 and what can I change so that it will run in Excel 97 and beyond?
I've pasted the subroutine into the Extended box. Oh, and I'm really an infant with this, so please try and communicate on that level.
Private Sub CommandButton1_Click()
Dim wsSheet As Worksheet
On Error Resume Next
Set wsSheet = Sheets(ComboBox1.Value & ComboBox2.Value)
If Not wsSheet Is Nothing Then
MsgBox ("The month you have selected already exists as a worksheet name. Please choose another month and try again.")
Exit Sub
Else
Sheets("Template").Select
Sheets("Template").Copy After:=Sheets("Template")
Sheets("Template (2)").Name = ComboBox1.Value & ComboBox2.Value
Sheets(ComboBox1.Value & ComboBox2.Value).Select
Sheets(ComboBox1.Value & ComboBox2.Value).Unprotect
Sheets(ComboBox1.Value & ComboBox2.Value).Shapes("ComboBox1").Delete
Sheets(ComboBox1.Value & ComboBox2.Value).Shapes("ComboBox2").Delete
Sheets(ComboBox1.Value & ComboBox2.Value).Shapes("CommandButton1").Delete
Sheets(ComboBox1.Value & ComboBox2.Value).Columns("J:N").Delete Shift:=xlToLeft
Sheets(ComboBox1.Value & ComboBox2.Value).Range("B2").FormulaR1C1 = "'" & ComboBox1.Value & " " & ComboBox2.Value
'Sheets(ComboBox1.Value & ComboBox2.Value).Tab.ColorIndex = -4142
Sheets(ComboBox1.Value & ComboBox2.Value).Protect
Exit Sub
End If
End Sub
posted by kc0dxh to computers & internet (11 answers total)
posted by BlzOfGlry at 6:21 PM on September 8, 2006