Share via

ListView column alignment

Anonymous
2014-12-15T10:03:36+00:00

Hi,

Using the code below, second column is not aligned right?

With ListView1

    .ColumnHeaders.Add , , "BU/SF", 100, lvwColumnLeft

    .ColumnHeaders.Add , , "Amount", 90, lvwColumnRight

    .View = 3

End With

 k = 1

        For j= 1 To .CurrentRegion.Columns.Count

            If .Offset(i, j).Value <> 0 Then

             strColumns = .Offset(3, j).Value

             strValues = Format(.Offset(i, j).Value, "#,###")

                ListView1.ListItems.Add , , strColumns

                ListView1.ListItems(k).SubItems(1) = strValues

                  k = k + 1

            End If

        Next j

End With

Microsoft 365 and Office | Excel | 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

2 answers

Sort by: Most helpful
  1. Anonymous
    2014-12-15T12:24:12+00:00

    thanks for the reply

    Regards,

    1 person found this answer helpful.
    0 comments No comments
  2. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2014-12-15T11:14:14+00:00

    Make a new file

    Add a Userform

    Add a ListView

    Add the code below

    Run the Userform

    I can not see the issue:

    Andreas.

    Private Sub UserForm_Initialize()

      Dim k As Integer

      With ListView1

        .ColumnHeaders.Add , , "BU/SF", 100, lvwColumnLeft

        .ColumnHeaders.Add , , "Amount", 90, lvwColumnRight

        .View = lvwReport

        For k = 1 To 5

          .ListItems.Add , , "A" & k

          .ListItems(.ListItems.Count).SubItems(1) = Format(k * 1000, "#,###")

        Next

      End With

    End Sub

    1 person found this answer helpful.
    0 comments No comments