How can I align excel cell from vb?

How can I align excel cell from vb?
Who is Participating?
vindevogelConnect With a Mentor Commented:
This example opens Excel, adds a value in a cell and aligns it to the right

Cut and paste this code in the click event of a command button to test it ...

You also have vbAlignLeft and vbAlignCenter

    Dim vExcel As Excel.Application
    Dim vSheet As Worksheet
    Set vExcel = New Excel.Application
    vExcel.Visible = True
    Set vSheet = vExcel.ActiveWorkbook.Sheets("Sheet1")
    vSheet.Cells(1, 1) = "Yves"
    vSheet.Range("A1", "A1").HorizontalAlignment = vbAlignRight
    Set vSheet = Nothing
    Set vExcel = Nothing

itacanAuthor Commented:
Thank you
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.