bassnsjp
06-02-2009, 06:43 AM
I'm using MS Office 2003 in an Windows XP Pro environment.
The code is on another PC that I cannot access so I must retype it so, please bare with me. The issue I'm having is that in testing the code in a small macro the column formatting works, but for whatever reason nearly the same code does not in the operational macro. I'm banging my head against the wall and hope that someone can help. It's frustrating to say the least.
Here is the test code:
Sub Testfmt()
Worksheets("Inv").Columns("C:D").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
End Sub
Here is the operational code:
Call Setup_wks ("Inv")
Sub Setup_wks(ByVal CURwksname As String)
Worksheets(CURwksname).Cells(3, 1) = "Part No"
Worksheets(CURwksname).Cells(3, 2) = "Description"
Worksheets(CURwksname).Cells(3, 3) = "Qty"
Worksheets(CURwksname).Cells(3, 4) = "Qty"
Worksheets(CURwksname).Cells(3, 5) = "Description"
Worksheets(CURwksname).Cells(3, 6) = "Part No"
Worksheets(CURwksname).Columns("C:D").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
etc.
etc.
End Sub
First three statements are processed with no problems, but once the .Columns statement is reached the control goes back to the main subroutine, which is two levels up from the Setup_wks subroutine. In that the main calls subroutine Finalize_wks which in turn calls Setup_wks. In stepping through the macro I confirmed the value of CURwksname is correct and the other cells are formatting with no problem. I also changed .Columns("C:D") to .Range("C:D") with the same results.
The test code works with no problems whatsoever on the same worksheet and data and it produces the desired results.
Any assistance would be greately appreciated, thanks in advance.
The code is on another PC that I cannot access so I must retype it so, please bare with me. The issue I'm having is that in testing the code in a small macro the column formatting works, but for whatever reason nearly the same code does not in the operational macro. I'm banging my head against the wall and hope that someone can help. It's frustrating to say the least.
Here is the test code:
Sub Testfmt()
Worksheets("Inv").Columns("C:D").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
End Sub
Here is the operational code:
Call Setup_wks ("Inv")
Sub Setup_wks(ByVal CURwksname As String)
Worksheets(CURwksname).Cells(3, 1) = "Part No"
Worksheets(CURwksname).Cells(3, 2) = "Description"
Worksheets(CURwksname).Cells(3, 3) = "Qty"
Worksheets(CURwksname).Cells(3, 4) = "Qty"
Worksheets(CURwksname).Cells(3, 5) = "Description"
Worksheets(CURwksname).Cells(3, 6) = "Part No"
Worksheets(CURwksname).Columns("C:D").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
etc.
etc.
End Sub
First three statements are processed with no problems, but once the .Columns statement is reached the control goes back to the main subroutine, which is two levels up from the Setup_wks subroutine. In that the main calls subroutine Finalize_wks which in turn calls Setup_wks. In stepping through the macro I confirmed the value of CURwksname is correct and the other cells are formatting with no problem. I also changed .Columns("C:D") to .Range("C:D") with the same results.
The test code works with no problems whatsoever on the same worksheet and data and it produces the desired results.
Any assistance would be greately appreciated, thanks in advance.