Hi,
I have one macro where i want to run the macro with save button instead of clicking "Run button" every time.
Below is my very small coding, i want to add some coding to run the macro whenever i save the file (Ctrl+S).
Sub Numberformat()
'
' Numberformat Macro
'
Columns("J:M").Select
Selection.Numberformat = "General"
Columns("J:J").Select
Selection.TextToColumns Destination:=Range("J1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 2), TrailingMinusNumbers:=True
End Sub
Hi Rafi,
Use a Workbook_BeforeSave event
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
<< YOUR CODE GOES HERE >>
End Sub
This code will go in the ThisWorkbook module of your workbook - see attached.
Regards
Phil
Hi Philip,
If i use your file, it is working 100%. Thanks a lot for your help.
I need one more help from you. I have attached my file with your coding. But this file is not working properly. Can you help me where it went wrong?
Hi Rafi,
This code will go in the ThisWorkbook module of your workbook - see attached.
Event code doesn't go in a 'normal' code module.
Regards
Phil