Vba code for User history log which is giving me a run-time error "13" mismatch

Status
Not open for further replies.

Kevo

New Member
Joined
Feb 4, 2024
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hello
Can you please assist with correcting the below VBA code as i am getting an error on the text in yellow-"Run-time error '13': Type mismatch." .Really appreciate any help here. Thanks in advance. Can you also provide full code solution as i am a novice when it comes to VBA

Note that Changes is my Worksheet name

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("C6:X999")) Is Nothing And Range("C" & Target.Row).Value <> Empty Then
If Changes.Range("H2").Value) = Target.Value Then Exit Sub
Dim ChngRow As Long
With Changes
ChngRow = .Range("A99999").End(xlUp).Row + 1
.Range("A" & ChngRow).Value = Now
.Range("B" & ChngRow).Value = ThisWorkbook.BuiltinDocumentProperties("Last Author")
.Range("C" & ChngRow).Value = ActiveSheet.Name
.Range("D" & ChngRow).Value = Target Address
.Range("E" & ChngRow).Value = .Range("H2").value
.Range("F" & ChngRow).Value = Target.Value

End With
End If
End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("C6:X999")) Is Nothing And Range("C" & Target.Row).Value <> Empty Then
Changes.Range("H2").Value = Target.Value
End If
End Sub





Basically what im doing is creating a User log history (Got a data input sheet where the above code is used) and then whenever a user makes changes to any cells in the data input sheet, these changes are showed in the Changes sheet name under the below columns

.Range("A" & ChngRow).Value = Now 'Changes the date and Time
.Range("B" & ChngRow).Value = ThisWorkbook.BuiltinDocumentProperties("Last Author") 'User
.Range("C" & ChngRow).Value = ActiveSheet.Name 'Sheet
.Range("D" & ChngRow).Value = Target Address 'Cell
.Range("E" & ChngRow).Value = .Range("H2").value 'Old Value
.Range("F" & ChngRow).Value = Target.Value 'New Value


H2 in Changes Sheet is the selected range
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
apologies......Im getting the error message on If Changes.Range("H2").Value) = Target.Value Then Exit Sub
 
Upvote 0
Duplicate to: VBA Code for User log history

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread. If you do not receive a response, you can "bump" it by replying to it yourself, though we advise you to wait 24 hours before doing so, and not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,914
Messages
6,175,351
Members
452,638
Latest member
Oluwabukunmi

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