VBA code only works in VBA screen and not when using the button to run the code?

Viewed 26

This code works fine when ran in the Developer Window, but does not work when using the button to control the macro? Please can someone let me know what I am doing wrong.

Sub FormatCells()

With ThisWorkbook.Sheets("Data")

Columns(4).NumberFormat = "@"
Columns(4).NumberFormat = "0000000"
Columns(7).NumberFormat = "dd/mm/yyyy"
 
End With
 
End Sub
0 Answers
Related