Syntax

expression.RightMargin

expression A variable that represents a PageSetup object.

Remarks

Margins are set or returned in points. Use the InchesToPoints method or the CentimetersToPoints method to convert measurements from inches or centimeters.

Example

This example sets the right margin of Sheet1 to 1.5 inches.

Visual Basic for Applications
Worksheets("Sheet1").PageSetup.RightMargin = _ Application.InchesToPoints(1.5)

This example sets the right margin of Sheet1 to 2 centimeters.

Visual Basic for Applications
Worksheets("Sheet1").PageSetup.RightMargin = _ Application.CentimetersToPoints(2)

This example displays the current right-margin setting for Sheet1.

Visual Basic for Applications
marginInches = Worksheets("Sheet1").PageSetup.RightMargin / _ Application.InchesToPoints(1) MsgBox "The current right margin is " & marginInches & " inches"
Change setting of right margin? Enlarge the right margin to 72 points? right margin Right Margin Property RightMargin rightmargin property

See also: