Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub coladd()
- Dim v
- v = Array("column1","column2,column3, column4")
- Dim wb As Workbook
- Set wb = Workbooks.Open("C:folderexcel.xls")
- With wb.Sheets("sheet1")
- For x = 0 To UBound(v)
- If .Cells(1, x + 1).Value = v(x) Then GoTo nnext
- If .Cells(1, x + 1) <> "" Then
- .Cells(1, x + 1).EntireColumn.Insert
- .Cells(1, x + 1).Value = v(x)
- End If
- If .Cells(1, x + 1) = "" Then
- .Cells(1, x + 1).Value = v(x)
- End If
- nnext:
- Next
- .Range("A1").CurrentRegion.SpecialCells(xlCellTypeBlanks).Value = 0
- End With
- wb.Save
- wb.Close False
- ActiveWorkbook.Save
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement