reusing code for different userfroms

ExHelper

New Member
Joined
Jan 17, 2012
Messages
1
I am a newbe. I have created 4 userforms to input seminar evaluation data for each of the 4 periods. Each UF has directly coded outputs to specific cells in 8 columns. I believe I could put the identical events into a module and call it up for each UF but I don't know how to get the option button output for each UF into its own columns on the spreadsheet. Here is a part of the code for one UF:

Option Explicit
Dim r As Variant
Private Sub kcmd_enter_Click()
r = Application.WorksheetFunction.CountA(Range("a:a")) + 1
'Insert k1 Knowledge rating
Select Case True
Case obk15
Cells(r, 1) = 5
Case obk14
Cells(r, 1) = 4
Case obk13
Cells(r, 1) = 3
Case obk12
Cells(r, 1) = 2
Case obk11
Cells(r, 1) = 1
Case obk1NA
Cells(r, 1) = "na"
Case Else: Cells(r, 1) = "No Data"
End Select

'Insert k2 skill rating
Select Case True
Case obk25
Cells(r, 2) = 5
Case obk24
Cells(r, 2) = 4
Case obk23
Cells(r, 2) = 3
Case obk22
Cells(r, 2) = 2
Case obk21
Cells(r, 2) = 1
Case obk2NA
Cells(r, 2) = "na"
Case Else: Cells(r, 2) = "No Data"
End Select
'insert comment
Cells(r, 7) = tbk7CMT.Text

Unload Me

UserFormS1.Show

End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top