Announcement

Collapse
No announcement yet.

Vertical Alignment in Macros - [SOLVED]

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

  • Vertical Alignment in Macros - [SOLVED]



    Hello,

    I'd be very grateful indeed for any help you can give me - this silly little problem is driving me mad!

    I work in the wine trade and often send out offers of wines in Excel with tasting notes. I do this so often that I've written a macro to format the notes for me, to save time doing it myself.

    My little macro works really well, except it won't set the vertical alignment to the top. The error message I receive says:

    Run Time Error '1004'

    Unable to set the VerticalAlignment property of the Range class.

    My code is below - can someone please tell me what I'm doing wrong??

    Sub FormatNotes()
    Dim i As Long
    For i = 4 To 200
    If Cells(i, 1) <> "" And Cells(i, 2) = "" And Cells(i, 4) = "" Then
    Range(Cells(i, 1), Cells(i, 8)).Select
    With Selection
    .Font.Italic = True
    .WrapText = True
    .MergeCells = True
    .VerticalAlignment = x1VAlignTop
    End With
    End If
    Next i

    End Sub

    ps - if anyone ever needs anything translated from french into english - let me know

    Kind regards, and thanks lots in advance for any help,

    Victoria

  • #2
    I&#039;m guessing that instead of:

    Code:
    .VerticalAlignment = x1VAlignTop
    you want:

    Code:
    .VerticalAlignment = xlVAlignTop
    I changed the "1" for an "l".

    Comment


    • #3
      You could try ;

      .VerticalAlignment = xlTop

      Roy
      Hope that Helps

      Roy

      New users should read the Forum Rules before posting

      For free Excel tools & articles visit my web site

      If I have helped you and you feel like putting your hand in your pocket please make a donation to Children in Need

      RoyUK's Web Site

      royUK's Database Form

      Where to paste code from the Forum

      About me.

      Comment


      • #4


        It works!! Thank you all so much!

        I&#039;m learning from a book, so I thought they were x one properties, instead of x L properties!

        What a relief.

        Thanks again

        Kind regards,

        Victoria

        Comment

        Working...
        X