Thanks Paul ... On Feb 18, 6:45 pm, Paul Schreiner <schreiner_p...@att.net> wrote: > This may not be the most elegant, but it works: > Assuming that your week numbers are in row 1, then: > > Option Explicit > Sub Seq_Columns() > Dim nCols, C > Application.ScreenUpdating = False > nCols = ActiveCell.SpecialCells(xlLastCell).Column > C = 2 > Do While C < nCols > If (Cells(1, C).Value <> "") Then > If (IsNumeric(Cells(1, C).Value)) Then > If (IsNumeric(Cells(1, C + 1).Value)) Then > If (Cells(1, C + 1).Value <> Cells(1, C).Value + 1) Then > Cells(1, C + 1).EntireColumn.Insert Shift:=xlToRight, > _ > CopyOrigin:=xlFormatFromLeftOrAbove > Cells(1, C + 1).Value = Cells(1, C).Value + 1 > nCols = nCols + 1 > If (Cells(1, C + 1).Value = 52) Then Exit Do > End If > End If > End If > End If > C = C + 1 > Loop > Application.ScreenUpdating = True > End Sub > > Paul > > ________________________________ > From: Sayyad1284 <anamika2...@gmail.com> > To: MS EXCEL AND VBA MACROS <excel-macros@googlegroups.com> > Cc: sayyad1...@hotmail.com > Sent: Fri, February 18, 2011 4:34:51 AM > Subject: $$Excel-Macros$$ Insert Column > > Helllo Experts, > > I have a situation as follows, > > my data is distributed in coloumns , represnts weeknumbers as > > 8 9 10 11 .. 52 > > some times if there are no values for a particular weeks then the > data will look as > > 8 13 14 15 16.... > > what i want is is there are gaps in weeks so the I need to insert no. > columns in between , > > for e.g. if there is 8 & next number is 13 , the program should add 4 > columns .. > > this needs to be done through out the range where ever there are no > consecutive weeks > > Need your suggestions > > -- > ---------------------------------------------------------------------------------- > > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links > :http://twitter.com/exceldailytip > 2. Join our LinkedIN group @http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials athttp://www.excel-macros.blogspot.com > 4. Learn VBA Macros athttp://www.quickvba.blogspot.com > 5. Excel Tips and Tricks athttp://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > Like our page on facebook , Just follow below > linkhttp://www.facebook.com/discussexcel
-- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel