cgmojoco
Well-known Member
- Joined
- Jan 15, 2005
- Messages
- 699
This snippet of a VBA routine is meant to insert a new column to the right of the selected column:
the xlToLeft seems to do the same thing as xlToRight.
Is there a simple way of inserting a column to the right of the selected column rather than the left other than in this case adding 1 to the colPAY integer like this?
The reason I am looking for this solution is that I find myself having to reset the colPAY integer to the actual column if I want to refer to the exact column anywhere later in my code and still have it make sense:
Code:
Sub NewColumn()
Dim colPAY As Integer
colPAY = Application.Match("Payment Source", Range("1:1"), 0)
Columns(colPAY).Insert Shift:=[B][COLOR=red]xlToLeft[/COLOR][/B]
End Sub
the xlToLeft seems to do the same thing as xlToRight.
Is there a simple way of inserting a column to the right of the selected column rather than the left other than in this case adding 1 to the colPAY integer like this?
Code:
Sub NewColumn()
Dim colPAY As Integer
colPAY = Application.Match("Payment Source", Range("1:1"), 0) [COLOR=red][B]+ 1
[/B][/COLOR] Columns(colPAY).Insert Shift:=[B][COLOR=#ff0000]xlToRight[/COLOR][/B]
End Sub
The reason I am looking for this solution is that I find myself having to reset the colPAY integer to the actual column if I want to refer to the exact column anywhere later in my code and still have it make sense:
Code:
colPAY = Application.Match("Payment Source", Range("1:1"), 0)