Tuesday, 25 September 2012

Excel VBA Macro To Concatenate First Column of Each Sheet In Main Sheet

Excel VBA Macro To Concatenate First Column of Each Sheet In Main Sheet

'First Column of Each Sheet Comes Side By Side(Concatenation Mode) in Main Sheet

Sub ConcateColumns()
Dim X As Integer
Dim Y As Integer
Dim Z As Integer

Dim W As Worksheet
Dim A As Integer

A = 1 'Variable for Column Increment In Main Sheet

For Each W In Worksheets

If W.Name <> Sheets("MAIN").Name Then
W.Activate

For X = 1 To 100

If Cells(X, 1) <> "" Then
Z = Z + 1 'Row Increment Variable
Sheets("MAIN").Cells(Z, A) = W.Cells(X, 1)
End If

Next X

A = A + 1 'Variable for Column Increment In Main Sheet

End If

Z = 0

Next W
End Sub

No comments:

Post a Comment

Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts