Hello:
I need a VB Macro to delete alternate column starting in column P.
SO basically delete Column P,R,T,V....EH
Please help and let me know if any questions.
Thank you
Riz Momin
Hello:
I need a VB Macro to delete alternate column starting in column P.
SO basically delete Column P,R,T,V....EH
Please help and let me know if any questions.
Thank you
Riz Momin
Last edited by rizmomin; 07-07-2013 at 10:15 PM.
Hi, Riz,
if you have solved the problem on your own you maybe should post the solution which worked for you - it might be of help for other users.
My suggestion would be
Ciao,![]()
Sub rizDeleteDeleteAltColumn() Dim lngCounter As Long 'For lngCounter = Cells(1, Columns.Count).End(xlToLeft).Column To 16 Step -2 For lngCounter = 138 To 16 Step -2 Columns(lngCounter).Delete Next lngCounter End Sub
Holger
Use Code-Tags for showing your code: [code] Your Code here [/code]
Please mark your question Solved if there has been offered a solution that works fine for you
another option
![]()
Sub ColAlternDelete1() Start = 15 lastcol = ActiveSheet.UsedRange.Columns.Count Names.Add "p", ActiveSheet.UsedRange.Offset(, Start).Resize(, lastcol - Start).Rows(1) [p] = [if(mod(column(p),2)=0,"",p)] [p].SpecialCells(4).EntireColumn.Delete End Sub
Last edited by patel45; 07-09-2013 at 01:28 AM.
If solved remember to mark Thread as solved
Hi Hahobe and Patel:
Both code will work for me.
Thank you both of you.
Riz Momin
Hi, patel45,
Start is dimmed but not used, UsedRange is not necessarily the range columns need to be deleted in since it may start in A1 and not K1, the name you enter stays in the workbook.
Ciao,![]()
Sub ColAlternDelete2() Names.Add "p", ActiveSheet.Range("P1:EH1") [p] = [If(Mod(Column(p),2)=1,"",p)] [p].SpecialCells(4).EntireColumn.Delete ActiveWorkbook.Names("p").Delete End Sub
Holger
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks