Monday, 10 September 2012

Excel VBA Macro To Segregating Data From One Sheet To Many

Excel VBA Macro To Segregating Data From One Sheet To Many 

Sub DATASEG()
Dim X As Integer
Dim y As Integer
Dim z As Integer
Dim a As Integer
Dim b As Integer
Dim C As Integer

a = 1

For X = 2 To 100

If Sheets("sheet2").Cells(X, 8) <> "" Then
Sheets.ADD.Name = Sheets("Sheet2").Cells(X, 8)
         'Cells(x,8)having the names on which we create the Sheets'

For z = 2 To 100
If InStr(LCase(Sheets("sheet2").Cells(z, 1)), LCase(Sheets("sheet2").Cells(X, 8))) Then
a = a + 1

For b = 1 To 6                    ' Having the data to segregate'
ActiveSheet.Cells(a, b) = Sheets("sheet2").Cells(z, b)
ActiveSheet.Cells(1, b) = Sheets("sheet2").Cells(1, b)
ActiveSheet.Cells(1, b).Font.Bold = True
Next b

End If
Next z

For C = 2 To 100
If ActiveSheet.Cells(C, 4) <> "" Then
ActiveSheet.Cells(2, 5) = C - 1
ActiveSheet.Cells(2, 6) = ActiveSheet.Cells(2, 6) + ActiveSheet.Cells(C, 4)
End If
Next C

End If
a = 1   ‘To make in every sheet data beginning from first row’

Next X
End Sub

No comments:

Post a Comment

Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts