N
nwarnoc1
Hi,
I write a lot of macros to simplify frequent steps, like turning the
AutoFilters on and off, i.e. toggling them.
Sub Toggle_AutoFilter()
Selection.AutoFilter
End Sub
That's probably my favorite. Use it all the time.
Another example is my Move On Enter macro that "toggles" from down to
right to off, based on the existing setting.
Sub Move_On_Enter()
'Toggle Move_On_Enter Feature
' 6/10/97
If Application.MoveAfterReturn = False Then
With Application
.MoveAfterReturn = True
.MoveAfterReturnDirection = xlDown
End With
ElseIf Application.MoveAfterReturnDirection = xlDown Then
Application.MoveAfterReturnDirection = xlToRight
ElseIf Application.MoveAfterReturnDirection = xlToRight Then
Application.MoveAfterReturn = False
End If
End Sub
So I'm trying to write one that will toggle the text orientation of the
selection from 0 to -90, and if it's not 0, then make it 0. I've tried
the following so far:
Sub ToggleTextOrientation()
If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation = -90 Then
Selection.Orientation = 0
End If
End Sub
I've also tried
If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation <> 0 Then
Selection.Orientation = 0
End If
AND
Select Case Selection.Orientation
Case 90
Selection.Orientation = 0
Case -90
Selection.Orientation = 0
Case 0
Selection.Orientation = 90
Case Else
Selection.Orientation = 0
End Select
Doesn't seem like it would be tricky. I'm just not looking at it right.
I finally put a watch on Selection.Orientation. I get
Watch :
Expression: Selection.Orientation
Value: -4128
Type: Variant/Long
Context: Module2.ToggleTextOrientation
OK, it's in the back of my mind that -4128 is the datatype code, or
something like that.
If it was related to the orientation, I would have thought the "Else"
conditions would handle it, but no such luck.
Right now, I'm drawing a blank on getting past that. Or perhaps it's
another problem entirely. Any ideas would be appreciate. It's not
urgent; it's just bugging me.
Thanks,
Neva
I write a lot of macros to simplify frequent steps, like turning the
AutoFilters on and off, i.e. toggling them.
Sub Toggle_AutoFilter()
Selection.AutoFilter
End Sub
That's probably my favorite. Use it all the time.
Another example is my Move On Enter macro that "toggles" from down to
right to off, based on the existing setting.
Sub Move_On_Enter()
'Toggle Move_On_Enter Feature
' 6/10/97
If Application.MoveAfterReturn = False Then
With Application
.MoveAfterReturn = True
.MoveAfterReturnDirection = xlDown
End With
ElseIf Application.MoveAfterReturnDirection = xlDown Then
Application.MoveAfterReturnDirection = xlToRight
ElseIf Application.MoveAfterReturnDirection = xlToRight Then
Application.MoveAfterReturn = False
End If
End Sub
So I'm trying to write one that will toggle the text orientation of the
selection from 0 to -90, and if it's not 0, then make it 0. I've tried
the following so far:
Sub ToggleTextOrientation()
If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation = -90 Then
Selection.Orientation = 0
End If
End Sub
I've also tried
If Selection.Orientation = 90 Then
Selection.Orientation = 0
ElseIf Selection.Orientation = 0 Then
Selection.Orientation = 90
ElseIf Selection.Orientation <> 0 Then
Selection.Orientation = 0
End If
AND
Select Case Selection.Orientation
Case 90
Selection.Orientation = 0
Case -90
Selection.Orientation = 0
Case 0
Selection.Orientation = 90
Case Else
Selection.Orientation = 0
End Select
Doesn't seem like it would be tricky. I'm just not looking at it right.
I finally put a watch on Selection.Orientation. I get
Watch :
Expression: Selection.Orientation
Value: -4128
Type: Variant/Long
Context: Module2.ToggleTextOrientation
OK, it's in the back of my mind that -4128 is the datatype code, or
something like that.
If it was related to the orientation, I would have thought the "Else"
conditions would handle it, but no such luck.
Right now, I'm drawing a blank on getting past that. Or perhaps it's
another problem entirely. Any ideas would be appreciate. It's not
urgent; it's just bugging me.
Thanks,
Neva