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,


  • I'm guessing that instead of:

    .VerticalAlignment = x1VAlignTop

    you want:

    .VerticalAlignment = xlVAlignTop

    I changed the "1" for an "l".

  • It works!! Thank you all so much!

    I'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,


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!