Horizontal Alignment

P

Philippe Perrault

I have a Excel document I am creating from data in a Access Database.

I have alot of cells that need to be aligned left, right or center.
Instead of using the Brute force method of defining an alignment for each
individual cell I want to call a Sub Procedure to do the alignment.

Here is my Sub I am calling.
Public Sub AlignRight( _
Optional ByRef rowStart As Integer, _
Optional ByRef rowEnd As Integer, _
Optional ByRef column As String)

Dim x as Integer

x = row start
For counter = rowStart To rowEnd
Range(column & x).HorizontalAlignment = xlRight
x = x +1
Next
End Sub

From my main body of code I call the Sub Procedure with the following line
Call AlignRight(20, 29, "A")

The code runs just fine but the excel document is not modified. The Code
has no problem creating the Excel file, writing the queries from the Access
Database to the Excel file and doing all the other formating I have defined
in the main body of the code but the Sub Procedure doesn't act on the the
Excel file. How do I make the Sub Procedure act on the Excel Spreadsheet?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top