Hi Guys,
The idea of the macros below is this.
Macro1:
when you click on any of these cells place user info in a cell
Macro2:
When you click on this other range of cells change the value of this cell to something else
The problem is making both work in one sheet, if you can think of a way to do this I would appreciate your help.
Regards, Jaems
Macro 1:
Option Explicit
Dim previousvalue
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim txtCells As String
'Record Last Value, before making the change
previousvalue = Target.Value
Const WS_RANGE As String = "e17, d21, d28, d35, d42, d49, d56, d63, d70, d78, d85" '<=== change to suit
On Error GoTo err_handler
Application.EnableEvents = False
If Not Application.Intersect(Target, Range(WS_RANGE)) Is Nothing Then
With Target
eSignCell
End With
End If
err_handler:
Application.EnableEvents = True
End Sub
FYI esigncell is just a public function to pick up some user info as follows
Public Sub eSignCell()
On Error Resume Next
ActiveCell.FormulaR1C1 = eSign()
End Sub
Macro2
This code also works but I want the two combined for one range do the below, for the other range of cells do the one above.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo err_handler
Dim strCell1 As String
Dim strCell2 As String
Const WS_RANGE As String = "G11:P11" '<=== change to suit; this defines the clickable cells
Application.EnableEvents = False
If Not Application.Intersect(Target, Range(WS_RANGE)) Is Nothing Then
With Target
'strGroup = .Offset(-3, 0) '<=== use this to read the Group Name of the changed value for the Log File
Select Case .Value
Case "¤": .Value = "¡"
.Font.Name = "Wingdings"
.Font.Color = vbRed
'LogInformation (ActiveSheet.Name & " - " & Target.Address & " - " & strGroup & " - from Access to Restricted")
Case Else: .Value = "¤"
.Font.Name = "Wingdings"
.Font.Color = vbBlue
'LogInformation (ActiveSheet.Name & " - " & Target.Address & " - " & strGroup & " - from Restricted to Access")
End Select
'Validate the cell, if the cell value is different from Original, if different, change cell colour
strCell1 = ActiveCell.Offset(0, 0).Value
strCell2 = ActiveCell.Offset(-1, 0).Value
If strCell1 <> strCell2 Then .Interior.ColorIndex = 6 Else .Interior.ColorIndex = 0
.Offset(1, 0).Select '<===Move 1 cell down
End With
End If
err_handler:
Application.EnableEvents = True
End Sub
Bookmarks