Hi, Let say I have an existing column called "TEST" in A1. How do I create VBA codes to do this: create a new column called "TEST2" to the right of "TEST" Thanks
Hi, Let say I have an existing column called "TEST" in A1. How do I create VBA codes to do this: create a new column called "TEST2" to the right of "TEST" Thanks
Last edited by doctortt; 11-25-2013 at 12:31 PM.
probably need to tweak this a bit
PaulOption Explicit Sub Macro1() Dim iFindCol As Long iFindCol = 0 On Error Resume Next iFindCol = Application.WorksheetFunction.Match("TEST", ActiveSheet.Rows(1), 0) On Error GoTo 0 If iFindCol = 0 Then Exit Sub Call ActiveSheet.Columns(iFindCol + 1).Insert(xlShiftToRight) ActiveSheet.Cells(1, iFindCol + 1).Value = "TEST2" End Sub
Yes, they codes work. Thanks