Excel VBA and error message - Microsoft Community


hi all,

using undernoted code simple log record changes made workbook however, when user double-clicks autofill range of cells getting run-time error '13'; type mismatch. can advise me of changes need make code avoid this?

in advance.

[html][/dim previousvalue

private sub worksheet_change(byval target range)
if target.value <> previousvalue then
sheets("log").cells(65000, 1).end(xlup).offset(1, 0).value = _
application.username & " changed cell " & " " & activesheet.name & " " & target.address _
& " " & previousvalue & " " & target.value & " at: " & format(time, "hh:mm:ss") & " on: " & format(date, "dd/mm/yy")
end if
end sub

private sub worksheet_selectionchange(byval target range)
previousvalue = target.value
end subhtml]

it simple:

if more 1 cell changed target.value returns array instead of value, hence rte.

you can exclude situation with
  if target.count > 1 exit sub

in both subs.

but @ end means code did not work.

therefore excel has build in track changes feature, see review\changes.

andreas.



Office / Excel / Windows 10 / Office 2010



Comments

Popular posts from this blog

Getting ErrorCode: 120018 when trying to access Microsoft account - Microsoft Community

The message was sent to a distribution list ‎(DL)‎ - Microsoft Community

Activation Error 0x8004FE93 - Microsoft Community