ALIGN text in single cell to right

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

ALIGN text in single cell to right

Post by sal21 »

Code: Select all

Private Sub FILL_FLEX()

    Dim C As Long, R As Long, I As Long

    With Me.MSFlexGrid1

        .Redraw = False

        For I = 0 To UBound(STRDBLIST, 2)

            .TextMatrix(I + 1, C + 0) = STRDBLIST(0, I)
            .TextMatrix(I + 1, C + 1) = STRDBLIST(1, I)
            
[b]' i need to align t the right all cells from here[/b]

            .TextMatrix(I + 1, C + 2) = STRDBLIST(2, I)
            .TextMatrix(I + 1, C + 3) = STRDBLIST(3, I)
            .TextMatrix(I + 1, C + 4) = STRDBLIST(4, I)
            .TextMatrix(I + 1, C + 5) = STRDBLIST(5, I)
            .TextMatrix(I + 1, C + 6) = STRDBLIST(6, I)
            .TextMatrix(I + 1, C + 7) = STRDBLIST(7, I)
            .TextMatrix(I + 1, C + 8) = STRDBLIST(8, I)
            .TextMatrix(I + 1, C + 9) = STRDBLIST(9, I)
            .TextMatrix(I + 1, C + 10) = STRDBLIST(10, I)
            .TextMatrix(I + 1, C + 11) = STRDBLIST(11, I)
            .TextMatrix(I + 1, C + 12) = STRDBLIST(12, I)
            .TextMatrix(I + 1, C + 13) = STRDBLIST(13, I)
            .TextMatrix(I + 1, C + 14) = STRDBLIST(14, I)
            .TextMatrix(I + 1, C + 15) = STRDBLIST(15, I)
            .TextMatrix(I + 1, C + 16) = STRDBLIST(16, I)
            .TextMatrix(I + 1, C + 17) = STRDBLIST(17, I)
            .TextMatrix(I + 1, C + 18) = STRDBLIST(18, I)
            .TextMatrix(I + 1, C + 19) = STRDBLIST(19, I)
            .TextMatrix(I + 1, C + 20) = STRDBLIST(20, I)
            .TextMatrix(I + 1, C + 21) = STRDBLIST(21, I)
[b] 'to here[/b]

        Next I

        .Redraw = True

        Me.LNRG.Caption = Format(.Rows - 1, "#,##0")
        DoEvents

    End With

End Sub

User avatar
HansV
Administrator
Posts: 75751
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: ALIGN text in single cell to right

Post by HansV »

Try this - I cannot test it myself:

Code: Select all

Private Sub FILL_FLEX()
    Dim C As Long, R As Long, I As Long, J As Long

    With Me.MSFlexGrid1
        .Redraw = False

        For I = 0 To UBound(STRDBLIST, 2)
            For J = 0 To 21
                .TextMatrix(I + 1, C + J) = STRDBLIST(J, I)
                If J > 1 Then
                    .Row = I + 1
                    .Col = C + j
                    .CellAlignment = flexAlignRightCenter
                Enf If
            Next J
        Next I

        .Redraw = True

        Me.LNRG.Caption = Format(.Rows - 1, "#,##0")
        DoEvents
    End With
End Sub
Regards,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

Re: ALIGN text in single cell to right

Post by sal21 »

HansV wrote:
04 Nov 2022, 20:10
Try this - I cannot test it myself:

Code: Select all

Private Sub FILL_FLEX()
    Dim C As Long, R As Long, I As Long, J As Long

    With Me.MSFlexGrid1
        .Redraw = False

        For I = 0 To UBound(STRDBLIST, 2)
            For J = 0 To 21
                .TextMatrix(I + 1, C + J) = STRDBLIST(J, I)
                If J > 1 Then
                    .Row = I + 1
                    .Col = C + j
                    .CellAlignment = flexAlignRightCenter
                Enf If
            Next J
        Next I

        .Redraw = True

        Me.LNRG.Caption = Format(.Rows - 1, "#,##0")
        DoEvents
    End With
End Sub
only, Enf...
and all work perfect!