Ironman
Well-known Member
- Joined
- Jan 31, 2004
- Messages
- 1,069
- Office Version
- 365
- Platform
- Windows
Hi
I currently have 2 separate procedures, 1 of the procedures runs for each sheet, that insert the same symbol into a cell in either Column I of Sheet "Training Log" or Column K of Sheet "Indoor Bike" (the code for the symbol insertion is identical for both sheets).
The only difference between the 2 procedures is the column number (and the sheet name).
There are other sheets in the workbook and I don't want the procedures to run for any of those.
Procedure 1:
Procedure 2:
I'd be really grateful if the 2 procedures can be combined into 1, so that if Excel identifies the current sheet as one of those in the 2 procedures then it will run.
Many thanks
I currently have 2 separate procedures, 1 of the procedures runs for each sheet, that insert the same symbol into a cell in either Column I of Sheet "Training Log" or Column K of Sheet "Indoor Bike" (the code for the symbol insertion is identical for both sheets).
The only difference between the 2 procedures is the column number (and the sheet name).
There are other sheets in the workbook and I don't want the procedures to run for any of those.
Procedure 1:
Code:
Sub GlobalCommentsCellTrainingLog()
If ActiveSheet.Name <> "Training Log" Then
MsgBox "This function will only run in Training Log", vbInformation, "Function Invalid in This Sheet"
Exit Sub
Else
End If
'If Selection.Value <> "" Then Exit Sub
If Selection.Column <> 9 Then
Ans = MsgBox("This function will only run in Column I!" & vbNewLine & _
"Would you like to move to column I now?", vbYesNo + vbExclamation, "Column Selection Error")
If Ans = vbNo Then Exit Sub
If Ans = vbYes Then
Dim i As Long
i = Selection.Row
Cells(i, 9).Select
End If
End If
On Error GoTo Quit
Code:
Sub GlobalCommentsCellIndoorBike()
If ActiveSheet.Name <> "Indoor Bike" Then
MsgBox "This function will only run in Indoor Bike Sheet", vbInformation, "Function Invalid in This Sheet"
Exit Sub
Else
End If
'If Selection.Value <> "" Then Exit Sub
If Selection.Column <> 11 Then
Ans = MsgBox("This function will only run in Column K!" & vbNewLine & _
"Would you like to move to column K now?", vbYesNo + vbExclamation, "Column Selection Error")
If Ans = vbNo Then Exit Sub
If Ans = vbYes Then
Dim i As Long
i = Selection.Row
Cells(i, 11).Select
End If
End If
On Error GoTo Quit
Many thanks