Excel VBA - running a macro before saving

I was looking for a way to invoke my macro just before saving my document. I found this, but when I injected my code into it, it does nothing. So I guess I missed something.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Set shtVO = Sheets("Voice orders") endRowVO = shtVO.Range("E" & Rows.Count).End(xlUp).Row For Row = 11 To endRowVO If IsEmpty(shtVO.Cells(Row, 23).Value) = False Then If shtVO.Cells(Row, 3).Value <> shtVO.Cells(Row, 23) Then If shtVO.Cells(Row, 1).Value Like "*MIG*" Then Else shtVO.Cells(Row, 1).Value = shtVO.Cells(Row, 1).Value + "MIG" End If End If End If Next Row End Sub 
+7
source share
1 answer

Put your code in ThisWorkbook module

Place your code here

+20
source

All Articles