Saturday, 8 December 2012

How To Group the Records of the Same Date in Main Sheet with Excel VBA Macro

Excel VBA Macro To Grouping Records of the Same Date in Main Sheet from Sub Sheet
'The Following Macro Pull Out The Records From Sub Sheet and Insert Into Main Sheet
'Based On Date Matching'

 Sub GroupingTransactions()
 Dim X As Integer
 Dim Y As Integer
 Dim z As Integer
 Dim A As Integer

 z = 0

 For X = 2 To 100
 If Sheets("Sub").Cells(X, 1) = "" Then Exit For

 For Y = 2 To 100
 If Sheets("Main").Cells(Y, 1) = "" Then Exit For

 If Sheets("Main").Cells(X + z, 1) = Sheets("Sub").Cells(Y, 1) Then
 z = z + 1
 Sheets("Main").Cells(X + z, 1).EntireRow.Insert
 For A = 1 To 26
 Sheets("Main").Cells(X + z, A) = Sheets("Sub").Cells(Y, A)
 Next A
 End If

 Next Y
 Next X

 End Sub



--------------------------------------------------------------------------------------------------------
Thanks, TAMATAM ; Business Intelligence & Analytics Professional
--------------------------------------------------------------------------------------------------------

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your open Feedback only related to this Blog Posts. Please note that I cannot respond to the Anonymous Comments.

Subscribe to Blog Posts by Email

ExcelKingdom-Popular Posts