Announcement

Collapse
No announcement yet.

Unconfigured Ad Widget

Collapse

Text Alignment Of Entire Column In Vba

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Text Alignment Of Entire Column In Vba

    I have run this code
    Code:
    For each sheet in worksheets
                sheet.Columns("A").ColumnWidth = 7.43
                sheet.Columns("A").VerticalAlignment = xlVAlignTop
                sheet.Columns("A").HorizontalAlignment = xlHAlignRight
    Next
    But when I go to format cell & look at the text alignment it is still general & bottom.

    Any Ideas??
    Thanks, Chuck

  • #2
    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:
    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.)
    Last edited by mikerickson; June 5th, 2007, 10:49.

    Comment


    • #3
      Re: Text Alignment Of Entire Column In Vba

      Miike,

      Thanks, the .cells did the trick. I will change the name but it did work without changing it.

      Chuck

      Comment


      • #4
        Re: Text Alignment Of Entire Column In Vba

        "sheet" isn't a reserved word, but its close enough that I had to look at the Object Browser to remind myself that it wasn't.

        Glad it worked out.

        Comment


        • #5
          Re: Text Alignment Of Entire Column In Vba

          You can try this aswell :
          Code:
          For i = 1 To Worksheets.Count
              Worksheets(i).Activate
              ActiveSheet.Columns("A").ColumnWidth = 7.43 
              ActiveSheet.Columns("A").VerticalAlignment = xlVAlignTop 
              ActiveSheet.Columns("A").HorizontalAlignment = xlHAlignRight 
          Next




          Originally posted by chucktx
          I have run this code
          Code:
          For each sheet in worksheets
                      sheet.Columns("A").ColumnWidth = 7.43
                      sheet.Columns("A").VerticalAlignment = xlVAlignTop
                      sheet.Columns("A").HorizontalAlignment = xlHAlignRight
          Next
          But when I go to format cell & look at the text alignment it is still general & bottom.

          Any Ideas??
          Thanks, Chuck
          Last edited by ByTheCringe2; June 6th, 2007, 14:56.

          Comment


          • #6
            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.
            .

            Comment

            Trending

            Collapse

            There are no results that meet this criteria.

            Working...
            X