VBA - Moving
Range.Move (collapse before)
Range objects include non printing characters such as spaces, tab characters and paragraph marks !!
Collapses the Range or Selection object to its start or end position (referring to an insertion point) and then moves the Range the specified number of units.
This method returns a value (Long) that indicates the number of units by which the start position has actually moved.
If it returns zero (0) then the move was unsuccessful.
lNoOfChars = oRange.Move(Unit:=wdUnits.wdParagraph, _
Count:=1)
Unit - The unit can only be one of the wdUnits enumerations. The default is wdCharacter.
You can only use wdLine when using a Selection object.
Count - The number of units to move. The default value is 1.
If Count is positive, the Range object is collapsed to its end position and moved forward.
If Count is negative, the Range object is collapsed to its start position and moved backward.
oRange.Move(Unit:=wdUnits.wdCell)
oRange.Move(Unit:=wdUnits.wdCharacter)
oRange.Move(Unit:=wdUnits.wdColumn)
oRange.Move(Unit:=wdUnits.wdParagraph)
oRange.Move(Unit:=wdUnits.wdRow)
oRange.Move(Unit:=wdUnits.wdSentence)
oRange.Move(Unit:=wdUnits.wdSection)
oRange.Move(Unit:=wdUnits.wdStory)
oRange.Move(Unit:=wdUnits.wdTable)
oRange.Move(Unit:=wdUnits.wdWord)
Using any other unit will generate a Bad Paramater error.
You can also control the collapse direction by using the Collapse method before using the Move method.
If the range is in the middle of a unit or isn't collapsed, moving it to the beginning or end of the unit counts as moving it one full unit.
Range.MoveStart
Moves the start position of the Range or Selection object a specified number of units.
This method returns a value (Long) that indicates the number of units by which the start position has actually moved.
If it returns zero (0) then the move was unsuccessful.
lNoOfChars = oRange.MoveStart(Unit:=wdUnits.wdCharacter, _
Count:=1)
Unit - The unit can only be one of the wdUnits enumerations. The default is wdCharacter.
You can only use wdLine when using a Selection object.
Count - The number of characters to move. The default is 1.
Range.MoveEnd
Moves the end position of the Range or Selection object a specified number of units.
This method returns the number of units by which the start position has moved.
If it returns zero (0) then the move was unsuccessful.
lNoOfChars = oRange.MoveEnd(Unit:=wdUnits.wdCharacter, _
Count:=1)
Unit - The unit can only be one of the wdUnits enumerations. The default is wdCharacter.
You can only use wdLine when using a Selection object.
Count - The number of units to move. The default is 1.
Range.MoveUntil (collapse before)
Collapses the Range or Selection object to an insertion point and moves it infront of the first specified character.
This method returns a value (Long) that indicates the number of units by which the Range has actually moved.
lNoOfChars = oRange.MoveUntil(Cset:= , _
Count:=1
Cset - One or more characters. This argument is case sensitive.
Count - The maximum number of characters to move. Can also be the wdForward or wdBackward constant. The default value is wdForward.
If Count is positive, the Range is moved forward (starting at the end position).
If Count is negative, the Range is moved backward (starting at the start position).
If Count is greater than 0 (zero), this method returns the number of characters moved plus 1.
If Count is less than 0 (zero), this method returns the number of characters moved minus 1.
If none of the characters are found the method returns zero (0) and the Range is not changed.
Range.MoveWhile (collapse before)
Collapses the Range or Selection object to an insertion point and moves it infront of the characters while any of the specified characters are found.
This method returns a value (Long) that indicates the number of units by which the Range has actually moved.
lNoOfChars = oRange.MoveWhile(Cset:= , _
Count:=1
Cset - One or more characters. This argument is case sensitive.
Count - The maximum number of characters to move. Can also be the wdForward or wdBackward constant. The default value is wdForward.
If Count is a positive, the Range is moved forward (starting at the end position).
If Count is negative, the Range is moved backward (starting at the start position).
If Count is greater than 0 (zero), this method returns the number of characters moved plus 1.
If Count is less than 0 (zero), this method returns the number of characters moved minus 1.
If none of the characters are found the method returns zero (0) and the Range is not changed.
Range.MoveStartUntil
Moves the start position of the Range or Selection object until one of the specified characters is found.
This method returns the number (Long) of characters that the start position has moved.
lNoOfChars = oRange.MoveStartUntil(Cset:= , _
Count:=1
Cset - One or more characters. This argument is case sensitive.
Count - The maximum number of characters to move. Can also be the wdForward or wdBackward constant. If Count is a positive, the Range is moved forward. If Count is negative, the Range is moved backward. The default value is wdForward.
If Count is greater than 0 (zero), this method returns the number of characters moved plus 1.
If Count is less than 0 (zero), this method returns the number of characters moved minus 1.
If none of the characters are found the method returns zero (0) and the Range is not changed.
If the start position is moved forward to a point beyond the end position, the Range is collapsed and both the start and end positions are moved together.
Range.MoveEndUntil
Moves the end position of the Range or Selection object until one of the specified characters is found.
This method returns the number (Long) of characters that the end position has moved.
lNoOfChars = oRange.MoveEndUntil(Cset:= , _
Count:=1
Cset - One or more characters. This argument is case sensitive.
Count - The maximum number of characters to move. Can also be the wdForward or wdBackward constant.
If Count is a positive, the Range is moved forward. If Count is negative, the Range is moved backward. The default value is wdForward.
If the movement is forwards then then the Range is expanded.
Range.MoveStartWhile
Moves the start position of the Range or Selection object while any of the specified characters are found.
This method returns the number (Long) of characters that the start position has moved.
oRange.MoveStartWhile(Cset:= , _
Count:=1)
Cset - One or more characters. This argument is case sensitive.
Count - The maximum number of characters to move. Can also be the wdForward or wdBackward constant.
If Count is a positive, the Range is moved forward. If Count is negative, the Range is moved backward. The default value is wdForward.
If none of the characters are found then the Range does not change.
Range.MoveEndWhile
Moves the end position of the Range or Selection object while any of the specified characters are found.
This method returns the number (Long) of characters that the end position has moved.
oRange.MoveEndWhile(Cset:= , _
Count:=1)
Cset - One or more characters. This argument is case sensitive.
Count - The maximum number of characters to move. Can also be the wdForward or wdBackward constant.
If Count is a positive, the Range is moved forward. If Count is negative, the Range is moved backward. The default value is wdForward.
Line, Start - Move the cursor to the start of the line
The following moves the start position of the Range to the start of the line.
objRange.MoveStart Unit:=wdUnits.wdLine, _
Count:=-1
Line, End - Move the cursor to the end of the line
The following moves the end of the Range to the end of the line.
oRange.MoveEnd Unit:=wdUnits.wdLine, _
Count:=1
Line, Up - Move the cursor up 3 lines
Paragraph, Start - Move the cursor to the start of a paragraph
Paragraph, End - Move the cursor to the end of a paragraph
The following collapses the Range and moves it to the end of the active paragraph.
oRange = ActiveDocument.Selection.Range
lNoOfChars = oRange.MoveUntil(Cset:=Chr$(13), _
Count:=wdConstants.wdForward)
Paragraph, Down - Move the cursor down 2 paragraphs
Document, Start - Move the cursor to the start of the document
Document, End - Move the cursor to the end of the document
Characters, 1 Backward - Move the end position of the range 1 character backward
The following moves the end of the Range one character backward, the range is reduced by one character.
oRange.MoveEnd Unit:=wdUnits.wdCharacter, _
Count:=-1
Characters, 1 Forward - Move the start position of the range 1 character forward
The following moves the start position of the Range one character forward (the selection size is reduced by one character).
oRange.MoveStart Unit:=wdUnits.wdCharacter, _
Count:=1
Words,2 Left - Move the selection 2 words to the left
The following collapses the Range and moves it forward through the next 100 characters in the document until the character "t" is found.
Set oRange = ActiveDocument.Words(1)
oRange.MoveUntil Cset:="t", _
Count:=100
The following collapses the Range and moves it over any consecutive tabs.
oRange.MoveWhile Cset:=wdUnits.vbTab, _
Count:=wdConstants.wdForward
The following collapses the Range and moves it past any of the following characters "a", "t" or "h" (uppercase or lowercase)
Set oRange = ActiveDocument.Characters(1)
oRange.MoveWhile Cset:="atiATI", _
Count:=wdConstants.wdForward
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext