• Conditional formatting: alignment (Excel 97 SR2)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Conditional formatting: alignment (Excel 97 SR2)

    Author
    Topic
    #365300

    I want to format a column of cells so that they alternate left and right text alignment. Can anyone help?
    Clark

    Viewing 0 reply threads
    Author
    Replies
    • #563413

      This macro will alternate the alignment of the current selection:

      Public Sub SetAlign()
      Dim oCell As Range
          For Each oCell In Selection
              If oCell.Row Mod 2 = 0 Then
                  oCell.HorizontalAlignment = xlHAlignLeft
              Else
                  oCell.HorizontalAlignment = xlHAlignRight
              End If
          Next oCell
      End Sub
      
    Viewing 0 reply threads
    Reply To: Conditional formatting: alignment (Excel 97 SR2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: