I had a macro in excel 2003 which rotated horizontal alignment of the selection.
Sub text_align() 'assign macro to Ctrl+q
With Selection
If .HorizontalAlignment = xlLeft Then
.HorizontalAlignment = xlCenter
ElseIf .HorizontalAlignment = xlCenter Then
.HorizontalAlignment = xlRight
ElseIf .HorizontalAlignment = xlRight Then
.HorizontalAlignment = xlLeft
End If
End With
End Sub
However, in 2007 something changed. Now it seems there is a NULL problem and I can not get into the loop. I changed to this:
Sub text_align() 'assign macro to Ctrl+q
With Selection
If .HorizontalAlignment = xlLeft Or IsNull(.HorizontalAlignment) Then
.HorizontalAlignment = xlCenter
ElseIf .HorizontalAlignment = xlCenter Then
.HorizontalAlignment = xlRight
ElseIf .HorizontalAlignment = xlRight Then
.HorizontalAlignment = xlLeft
End If
End With
End Sub
and now it only rotates between center and right (i never get left align). I use this for entire column selections (with headers) and with multiple range selections. Does anyone have any ideas. Does excel 2007 now see a selection range differently?
Thanks in advance
Heather
Bookmarks