Text Alignment Of Entire Column In Vba

  • I have run this code

    Code
    1. For each sheet in worksheets
    2. sheet.Columns("A").ColumnWidth = 7.43
    3. sheet.Columns("A").VerticalAlignment = xlVAlignTop
    4. sheet.Columns("A").HorizontalAlignment = xlHAlignRight
    5. Next


    But when I go to format cell & look at the text alignment it is still general & bottom.


    Any Ideas??
    Thanks, Chuck

  • Re: Text Alignment Of Entire Column In Vba


    The variable sheet has an unfortunate name. It's close to a VB term, which may be the cause of your problem. Substituting another name might set things right. If that doesn't work, I'd try qualifying the columns with .Cells as in

    Code
    1. xShet.Columns("A").Cells.HorizontalAlignment = xlHAlignRight


    Also, if you have two workbooks open, it might be confused as to which worksheets to cycle through.
    (That's odd, if you copy/pasted that code from your VB editor, worksheets should be capitalized. When that kind of thing happens to me, deleting and retyping a letter usualy wakes Excel up.)

  • Re: Text Alignment Of Entire Column In Vba


    You can try this aswell :

    Code
    1. For i = 1 To Worksheets.Count
    2. Worksheets(i).Activate
    3. ActiveSheet.Columns("A").ColumnWidth = 7.43
    4. ActiveSheet.Columns("A").VerticalAlignment = xlVAlignTop
    5. ActiveSheet.Columns("A").HorizontalAlignment = xlHAlignRight
    6. Next






    Quote from chucktx

    I have run this code

    Code
    1. For each sheet in worksheets
    2. sheet.Columns("A").ColumnWidth = 7.43
    3. sheet.Columns("A").VerticalAlignment = xlVAlignTop
    4. sheet.Columns("A").HorizontalAlignment = xlHAlignRight
    5. Next


    But when I go to format cell & look at the text alignment it is still general & bottom.


    Any Ideas??
    Thanks, Chuck

  • Re: Text Alignment Of Entire Column In Vba


    niket1981, Welcome to the forum. However please read the rules and use code tags for VBA. I have added them for you this time, but normally the post would be deleted.