Share via

Vba macro to select 2 columns in active table

Anonymous
2018-06-18T17:05:48+00:00

Hello 

I need a macro to select the column where the cursor is inside a table plus the adjacent column. Then change the formatting, like font name and size, just in the selected columns without affecting the other column(s) in the same table. Is it possible?

Thanks  in advance

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
2018-06-18T23:19:48+00:00

To deal with the column to the right of the column in which you have the selection, use:

Dim crange As Range

Set crange = Selection.Cells(1).Range

crange.MoveEnd wdColumn, 1

crange.Select

With Selection.Font

.Name = "Algerian"

.Size = 16

End With

Selection.Collapse wdCollapseStart

To deal with the column to the left, use

Dim crange As Range

Selection.MoveLeft wdCell, 1

Set crange = Selection.Cells(1).Range

crange.MoveEnd wdColumn, 1

crange.Select

With Selection.Font

.Name = "Algerian"

.Size = 16

End With

Selection.Collapse wdCollapseStart

Selection.MoveRight wdCell, 1

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Charles Kenyon 167.7K Reputation points Volunteer Moderator
    2018-06-18T20:43:43+00:00

    Hi,

    Yes it is possible. I am assuming you mean with a macro.

    Adjacent column to the left or to the right?

    I hope this information helps. Please let me know if you have any more questions or require further help.

    Regards

    Was this answer helpful?

    0 comments No comments