Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("E1").Resize(Rows.Count)) Is Nothing Then
With Target
.Copy
.Offset(, 11).Activate
ActiveSheet.Pictures.Paste
.Activate
End With
End If
End Sub
Picture ?
Yes you can use Excel's camera tool to take the snapshot, and automate it using some simple VBA
Do you want to retain successive snapshots?
Or value ?
- do you simply want the value in cells P1 (...etc) amended ?
How do you intend using the snapshots ?
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("P1").Resize(Rows.Count)) Is Nothing Then
Cancel = True
Application.EnableEvents = False
Target.Offset(, -11).Value = Target.Value
Application.EnableEvents = True
End If
If Not Intersect(Target, Range("E1").Resize(Rows.Count)) Is Nothing Then
Cancel = True
Application.EnableEvents = False
Target.Value = Target.Offset(, 11).Value
Application.EnableEvents = True
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("E1").Resize(Rows.Count)) Is Nothing Then
Target.Offset(, 11).Value = Target.Value
End If
End Sub
Place this code in the sheet code window
(right-click sheet tab \ View Code \ paste code into that window)
Amend the values a few times in E1 and E2 and tell me what requires changing
VBA Code:Private Sub Worksheet_Change(ByVal Target As Range) If Target.Count > 1 Then Exit Sub If Not Intersect(Target, Range("E1").Resize(Rows.Count)) Is Nothing Then With Target .Copy .Offset(, 11).Activate ActiveSheet.Pictures.Paste .Activate End With End If End Sub
Try this
Change the value in E1 as before
Replace with value in E1 by right-click in either P1 or E1 etc
Delete previous code and replace with this
VBA Code:Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) If Target.Count > 1 Then Exit Sub If Not Intersect(Target, Range("P1").Resize(Rows.Count)) Is Nothing Then Cancel = True Application.EnableEvents = False Target.Offset(, -11).Value = Target.Value Application.EnableEvents = True End If If Not Intersect(Target, Range("E1").Resize(Rows.Count)) Is Nothing Then Cancel = True Application.EnableEvents = False Target.Value = Target.Offset(, 11).Value Application.EnableEvents = True End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) If Target.Count > 1 Then Exit Sub If Not Intersect(Target, Range("E1").Resize(Rows.Count)) Is Nothing Then Target.Offset(, 11).Value = Target.Value End If End Sub
'declare these 2 variables at top of sheet module ABOVE all procedures
Private oldvalue As String, Ref As String
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range("C2:C156"), Target) Is Nothing Then
If Target.Address = Ref Then
Application.EnableEvents = False
If oldvalue <> Target.Value Then Target.Offset(, 17).Value = oldvalue
Application.EnableEvents = True
End If
oldvalue = ""
Ref = ""
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection.Count <> 1 Then Exit Sub
If Not Intersect(Range("C2:C156"), Target) Is Nothing Then
oldvalue = Target.Value
Ref = Target.Address
End If
End Sub
apologies i went out for walk and typed it from my phone, so hazard a guess on columns and cells??
what has happened to columns P and E ?