Thursday, January 09, 2014

Adding Dynamic Column to Excel

Adding Dynamic Column to Excel
Following function will add one column at  location D for all the sheets in opened excel document.

Sub AddColumnUPdateHeader()


For X = 1 To Worksheets.Count
 Sheets(X).Select
 Columns("D:D").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove


Next X

End Sub

Tuesday, January 07, 2014

Macro for Excel to get Count and Names of Sheets of excel documents

Following routing will update Cell B2 with count of total numbers of sheet and Update Column C with names of sheets.

Sub ReadNames()

Range("B2") = Worksheets.Count

For X = 1 To Worksheets.Count

Range("C" & X).Value = Worksheets(X).Name

Next X

End Sub