Hello, I'm having a wierd issue with vba and it's driving me nuts. I have a macro that produces pricelists and outputs them to pdf, the macro produces bot english and french pdf versions so when it comes to french I have to convert the decimal separator to a comma. problem is the sheet does not take the formatting, the column widths don't get adjusted and the numbers do not get 2 decimal places. But when i put a break point to see where the problem is everything works fine and it takes all the formatting as it should. I have tried turning screen updating back on for this section of code, I have tried making the sheet recalculate, none of it seems to work. please help.
Chris
Application.DecimalSeparator = ","
Application.ThousandsSeparator = " "
Application.UseSystemSeparators = False
Sub ColumnSizingILP(SheetNum As Worksheet)
'Resizes Columns and sets fonts for interchange PDF lists
Dim ColWidth As Single ' Column width
On Error Resume Next
'Set Row Height
With SheetNum
With Cells
.HorizontalAlignment = xlHAlignCenter
.VerticalAlignment = xlVAlignBottom
.RowHeight = 13
End With
With Range("A1").Cells
.HorizontalAlignment = xlHAlignCenter
.VerticalAlignment = xlVAlignBottom
.RowHeight = 26
End With
'Set Fonts
With Range("A:A,D:E,I:I,L:M").Font
.Name = "Arial"
.Size = 9
End With
With Range("B:B,C:C,F:F,J:J,K:K,N:N").Font
.Name = "Arial"
.Size = 8
End With
With Range("A1:N1").Font
.Name = "Arial"
.Size = 8.5
.Bold = True
End With
'Set Column Widths and alignment
With Range("A:A,I:I").Cells
.HorizontalAlignment = xlHAlignLeft
.IndentLevel = 1
.ColumnWidth = 10
End With
With Range("B:B,J:J").Cells
.HorizontalAlignment = xlHAlignCenter
.ColumnWidth = 7
End With
With Range("B1,J1").Cells
.WrapText = True
End With
With Range("D:E,L:M").Cells
.NumberFormat = "0.00"
.HorizontalAlignment = xlHAlignRight
.IndentLevel = 1.5
.ColumnWidth = 7
End With
With Range("C:C,K:K").Cells
.HorizontalAlignment = xlHAlignCenter
.ColumnWidth = 6
End With
With Range("F:F,N:N").Cells
.HorizontalAlignment = xlHAlignCenter
.ColumnWidth = 7
End With
With Range("B1:F1,I1:N1").Cells
.HorizontalAlignment = xlHAlignCenter
End With
With Range("D1:E1,L1:M1").Cells
.HorizontalAlignment = xlHAlignCenter
.IndentLevel = 0
End With
With Range("G:H").Cells
.HorizontalAlignment = xlHAlignLeft
.ColumnWidth = 0.25
End With
'Autofits Interchange Column to fit long codes while keeping the minimum
ColWidth = Columns("B:B").ColumnWidth
Range("B:B").EntireColumn.AutoFit
Range("J:J").EntireColumn.AutoFit
If Columns("B:B").ColumnWidth < ColWidth Or Columns("J:J").ColumnWidth < ColWidth Then
Columns("B:B,J:J").ColumnWidth = ColWidth
End If
End With
End Sub
Bookmarks