How can I reduce repetative code
Use called procedures
Private Sub OptionButton1_Click()
Call myProc
End Sub
Private Sub OptionButton2_Click()
Call myProc
End Sub
Private Function myProc()
Workbooks.Open ... 'etc
'other code
End Sub
If each button opens a different workbook, add an argument
Private Sub OptionButton1_Click()
Call myProc("C:\test\Book1.xls")
End Sub
Private Sub OptionButton2_Click()
Call myProc("C:\test\Book2.xls")
End Sub
Private Function myProc(ByVal Filename As String)
Workbooks.Open Filename
'other code
End Sub
--
__________________________________
HTH
Bob
"leerem" wrote in message
...
I have set up a userform with all the weeks of the year as optionbuttons to
save data too, with a command button to activate depending on which
optionbutton has been made true. My question: Instead of having to repeat
the
same code over and over again stating open new workbook / name workbook /
copy data to workbook / save data / close workbook. a good 40 lines of
code
for each option button. Is there away around this?
|