You can record it with the macro recorder.

Then you will get the VBA code.