+ Reply to Thread
Results 1 to 32 of 32

Transfer data from Input sheet to output sheet on condition

Hybrid View

Parth007 Transfer data from Input... 07-08-2015, 07:27 AM
JOHN H. DAVIS Re: Transfer data from Input... 07-08-2015, 10:03 AM
Parth007 Re: Transfer data from Input... 07-08-2015, 10:42 AM
JOHN H. DAVIS Re: Transfer data from Input... 07-08-2015, 10:52 AM
Parth007 Re: Transfer data from Input... 07-08-2015, 10:55 AM
JOHN H. DAVIS Re: Transfer data from Input... 07-08-2015, 10:57 AM
Parth007 Re: Transfer data from Input... 07-09-2015, 03:34 AM
JOHN H. DAVIS Re: Transfer data from Input... 07-09-2015, 06:19 AM
Parth007 Re: Transfer data from Input... 07-09-2015, 06:38 AM
JOHN H. DAVIS Re: Transfer data from Input... 07-09-2015, 08:26 AM
Parth007 Re: Transfer data from Input... 07-09-2015, 08:53 AM
Parth007 Re: Transfer data from Input... 07-09-2015, 09:25 AM
Parth007 Re: Transfer data from Input... 07-09-2015, 09:11 AM
LordLoki Re: Transfer data from Input... 07-09-2015, 09:32 AM
Parth007 Re: Transfer data from Input... 07-09-2015, 09:48 AM
Parth007 Re: Transfer data from Input... 07-09-2015, 10:30 AM
JOHN H. DAVIS Re: Transfer data from Input... 07-09-2015, 02:00 PM
LordLoki Re: Transfer data from Input... 07-09-2015, 11:57 AM
Parth007 Re: Transfer data from Input... 07-10-2015, 05:52 AM
Parth007 Re: Transfer data from Input... 07-10-2015, 03:54 AM
Parth007 Re: Transfer data from Input... 07-10-2015, 06:37 AM
LordLoki Re: Transfer data from Input... 07-10-2015, 07:18 AM
Parth007 Re: Transfer data from Input... 07-10-2015, 07:34 AM
LordLoki Re: Transfer data from Input... 07-10-2015, 07:45 AM
Parth007 Re: Transfer data from Input... 07-10-2015, 07:47 AM
LordLoki Re: Transfer data from Input... 07-10-2015, 08:00 AM
LordLoki Re: Transfer data from Input... 07-10-2015, 08:09 AM
Parth007 Re: Transfer data from Input... 07-10-2015, 09:07 AM
Parth007 Re: Transfer data from Input... 07-13-2015, 03:40 AM
LordLoki Re: Transfer data from Input... 07-13-2015, 04:54 AM
Parth007 Re: Transfer data from Input... 07-13-2015, 05:48 AM
LordLoki Re: Transfer data from Input... 07-13-2015, 08:22 AM
  1. #1
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Red face Transfer data from Input sheet to output sheet on condition

    Hello Experts,

    Need you assistance in transferring data from Input sheet to Output sheet on conditions..

    Please see the attached File..

    Input Sheet have Column C (Values as 1,2,3) & Data from (Column E to Column U)

    Now Transfer all Data from INput sheet to Output on below condition
    1) If "Column C" Cell value = 1 then copy that row to output sheet under row named ("1 TeraByte") from COlumn A to Column Q

    2) If "Column C" Cell value = 2 then copy that row to output sheet under row named ("1 MegaByte") from COlumn A to Column Q

    3) If "Column C" Cell value = 2 then copy that row to output sheet under row named ("1 TeraByte") from COlumn A to Column Q


    Initially for sample data i have inputted only 5 rows.. the data can be more hence the ouptut file layout should not undergo any change.. only the rows should be added in between the Row data header & the Subtotal...

    Also the Conditions are now for value = 1,2,3.. if it grows.. iw ill change the code accordingly...

    Puzzled


    Attached Files Attached Files
    Last edited by Parth007; 07-13-2015 at 06:00 AM.
    Regards
    Parth

    I appreciate your feedback. Hit * if u Like.
    Rules - http://www.excelforum.com/forum-rule...rum-rules.html

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Transfer data from Input sheet to output sheet on condition

    Maybe:

    Sub Parth007yy()
    Dim i As Long, t As Long
    Dim u As Range, v As Range, w As Range
    Dim wsIn As Worksheet, wsOut As Worksheet
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
    Set wsIn = Sheets("Input")
    Set wsOut = Sheets("Output")
    With wsIn
    t = wsOut.Range("A" & Rows.Count).End(3).Row
    For i = .Range("C" & Rows.Count).End(3).Row To 2 Step -1
    Select Case .Cells(i, "C")
    Case Is = 1
    Set u = wsOut.Columns(1).Find("1 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not u Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(u.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set u = Nothing
    Case Is = 2
    Set v = wsOut.Columns(1).Find("2 MegaByte", LookIn:=xlValues, lookat:=xlPart)
        If Not v Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(v.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set v = Nothing
    Case Is = 3
    Set w = wsOut.Columns(1).Find("3 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not w Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(w.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set w = Nothing
    End Select
    Next i
    End With
    t = wsOut.Range("A" & Rows.Count).End(3).Row
    With wsOut
        For Each numrange In .Columns(10).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
        For Each numrange In .Columns(13).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
    For i = 15 To 17
        For Each numrange In .Columns(i).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
    Next i
    nodata:
    On Error Resume Next
    .Range(.Cells(13, 1), .Cells(t, 1)).SpecialCells(4).EntireRow.Delete
    End With
    On Error GoTo 0
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With
    End Sub

  3. #3
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hi john,

    GRT it worked well on my sample sheet.. will run the same on My actual huge data earliest by tmrw & revert ..
    But puzzled as to how do i remove the old data first before i run this code..
    It will add the data on every run..

    can we just delete the existing data from Output sheet (Not the Headers rows & Sub total row & then execute macro

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Transfer data from Input sheet to output sheet on condition

    Try:

    Sub Parth007yy()
    Dim i As Long, t As Long
    Dim u As Range, v As Range, w As Range
    Dim wsIn As Worksheet, wsOut As Worksheet
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
    Set wsIn = Sheets("Input")
    Set wsOut = Sheets("Output")
    On Error Resume Next
    wsOut.Range("B13:B" & Range("A" & Rows.Count).End(3).Row).SpecialCells(xlCellTypeConstants, xlTextValues).EntireRow.Delete
    On Error GoTo 0
    With wsIn
    t = wsOut.Range("A" & Rows.Count).End(3).Row
    For i = .Range("C" & Rows.Count).End(3).Row To 2 Step -1
    Select Case .Cells(i, "C")
    Case Is = 1
    Set u = wsOut.Columns(1).Find("1 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not u Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(u.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set u = Nothing
    Case Is = 2
    Set v = wsOut.Columns(1).Find("2 MegaByte", LookIn:=xlValues, lookat:=xlPart)
        If Not v Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(v.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set v = Nothing
    Case Is = 3
    Set w = wsOut.Columns(1).Find("3 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not w Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(w.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set w = Nothing
    End Select
    Next i
    End With
    t = wsOut.Range("A" & Rows.Count).End(3).Row
    With wsOut
        For Each numrange In .Columns(10).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
        For Each numrange In .Columns(13).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
    For i = 15 To 17
        For Each numrange In .Columns(i).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
    Next i
    nodata:
    On Error Resume Next
    .Range(.Cells(13, 1), .Cells(t, 1)).SpecialCells(4).EntireRow.Delete
    End With
    On Error GoTo 0
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With
    End Sub

  5. #5
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Perfect ..Thanks A ton.. its working ausome on sample data..
    Will check with the actual data by tomorrow & will revert

    Thanks a lot JOHN !!!!

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Transfer data from Input sheet to output sheet on condition

    You're always welcome. Hope it works for you on real data.

  7. #7
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hello John,

    It Did work fwhen i added one more condition....

    Before testing it on real data please let me know the addition & changes i done in code is correct or not..
    As in real data i have 20 conditions..


    Currently in sheet there were 3 rows..

    1 TeraByte
    2 MegaByte
    3 TeraByte

    I added one more condition..."4 TeraByte"

    and did Addition in the code


    I added

    
    Dim z As Range 'AT the start of macro
    
    'Added Code in Case Body
    
    Case Is = 4
    Set z = wsOut.Columns(1).Find("4 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z = Nothing
    and where ever there was End(3).Row i Changed it to "End(4).Row"

    Please correct me if i am wrong.

    Below is the complete Code

    Sub Parth007yy()
    Dim i As Long, t As Long
    Dim u As Range, v As Range, w As Range, z As Range
    Dim wsIn As Worksheet, wsOut As Worksheet
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
    Set wsIn = Sheets("Input")
    Set wsOut = Sheets("Output")
    On Error Resume Next
    wsOut.Range("B13:B" & Range("A" & Rows.Count).End(4).Row).SpecialCells(xlCellTypeConstants, xlTextValues).EntireRow.Delete
    On Error GoTo 0
    With wsIn
    t = wsOut.Range("A" & Rows.Count).End(4).Row
    For i = .Range("C" & Rows.Count).End(4).Row To 2 Step -1
    Select Case .Cells(i, "C")
    Case Is = 1
    Set u = wsOut.Columns(1).Find("1 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not u Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(u.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set u = Nothing
    Case Is = 2
    Set v = wsOut.Columns(1).Find("2 MegaByte", LookIn:=xlValues, lookat:=xlPart)
        If Not v Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(v.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set v = Nothing
    Case Is = 3
    Set w = wsOut.Columns(1).Find("3 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not w Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(w.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set w = Nothing
    Case Is = 4
    Set z = wsOut.Columns(1).Find("4 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z = Nothing
    End Select
    Next i
    End With
    t = wsOut.Range("A" & Rows.Count).End(4).Row
    With wsOut
        For Each numrange In .Columns(10).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
        For Each numrange In .Columns(13).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
    For i = 15 To 17
        For Each numrange In .Columns(i).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
    Next i
    nodata:
    On Error Resume Next
    .Range(.Cells(13, 1), .Cells(t, 1)).SpecialCells(4).EntireRow.Delete
    End With
    On Error GoTo 0
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With
    End Sub

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Transfer data from Input sheet to output sheet on condition

    Looks good to me.

  9. #9
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hi John

    Its not working.. coz their are 9 conditions & one row added in each block as per source file..

    Please check the attached file.. sorry for inconvinence

    code attached in module..
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Transfer data from Input sheet to output sheet on condition

    Try:

    Sub Parth007yy()
    Dim i As Long, t As Long
    Dim j As String, m As String, o As String, p As String, q As String
    Dim rcell As Range, u As Range, v As Range, w As Range, z As Range, z1 As Range, z2 As Range, z3 As Range, z4 As Range, z5 As Range
    Dim wsIn As Worksheet, wsOut As Worksheet
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
    Set wsIn = Sheets("Input")
    Set wsOut = Sheets("Output")
    On Error Resume Next
    wsOut.Range("B13:B" & Range("A" & Rows.Count).End(9).Row).SpecialCells(xlCellTypeConstants, xlTextValues).EntireRow.Delete
    On Error GoTo 0
    With wsIn
    t = wsOut.Range("A" & Rows.Count).End(3).Row
    For i = .Range("C" & Rows.Count).End(3).Row To 2 Step -1
    Select Case .Cells(i, "C")
    Case Is = 1
    Set u = wsOut.Columns(1).Find("1 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not u Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(u.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set u = Nothing
    Case Is = 2
    Set v = wsOut.Columns(1).Find("2 MegaByte", LookIn:=xlValues, lookat:=xlPart)
        If Not v Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(v.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set v = Nothing
    Case Is = 3
    Set w = wsOut.Columns(1).Find("3 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not w Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(w.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set w = Nothing
    Case Is = 4
    Set z = wsOut.Columns(1).Find("4 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z = Nothing
    Case Is = 5
    Set z1 = wsOut.Columns(1).Find("5 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z1 Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z1.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z1 = Nothing
    Case Is = 6
    Set z2 = wsOut.Columns(1).Find("6 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z2 Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z2.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z2 = Nothing
    Case Is = 7
    Set z3 = wsOut.Columns(1).Find("7 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z3 Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z3.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z3 = Nothing
    Case Is = 8
    Set z4 = wsOut.Columns(1).Find("8 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z4 Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z4.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z4 = Nothing
    Case Is = 9
    Set z5 = wsOut.Columns(1).Find("9 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z5 Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z5.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z5 = Nothing
    End Select
    Next i
    End With
    t = wsOut.Range("A" & Rows.Count).End(3).Row
    With wsOut
        For Each numrange In .Columns(10).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
        For Each numrange In .Columns(13).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
    For i = 15 To 17
        For Each numrange In .Columns(i).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
    Next i
    nodata:
    On Error Resume Next
    .Range(.Cells(13, 1), .Cells(t, 1)).SpecialCells(4).EntireRow.Delete
    On Error GoTo 0
    j = ""
    m = ""
    o = ""
    p = ""
    q = ""
    For Each rcell In .Range("A13:A96") ' & .Range("A" & Rows.Count).End(3).Row)
        If rcell Like "*Byte Total*" Then
            .Cells(rcell.Row - 1, "J").Formula = .Cells(rcell.Row - 2, "J").Formula
            .Cells(rcell.Row, "J").Formula = .Cells(rcell.Row - 1, "J").Formula
            j = j & "J" & rcell.Row & "+"
            j = j
            .Cells(rcell.Row - 1, "M").Formula = .Cells(rcell.Row - 2, "M").Formula
            .Cells(rcell.Row, "M").Formula = .Cells(rcell.Row - 1, "M").Formula
            m = m & "M" & rcell.Row & "+"
            m = m
            .Cells(rcell.Row - 1, "O").Formula = .Cells(rcell.Row - 2, "O").Formula
            .Cells(rcell.Row, "O").Formula = .Cells(rcell.Row - 1, "O").Formula
            o = o & "O" & rcell.Row & "+"
            o = o
            .Cells(rcell.Row - 1, "P").Formula = .Cells(rcell.Row - 2, "P").Formula
            .Cells(rcell.Row, "P").Formula = .Cells(rcell.Row - 1, "P").Formula
            p = p & "P" & rcell.Row & "+"
            p = p
            .Cells(rcell.Row - 1, "Q").Formula = .Cells(rcell.Row - 2, "Q").Formula
            .Cells(rcell.Row, "Q").Formula = .Cells(rcell.Row - 1, "Q").Formula
            q = q & "Q" & rcell.Row & "+"
            q = q
        End If
    Next rcell
    t = wsOut.Range("A" & Rows.Count).End(3).Row
    j = Left(j, Len(j) - 1)
    Cells(t, "J").Formula = "=" & Left(j, Len(j) - 1)
    m = Left(m, Len(m) - 1)
    Cells(t, "M").Formula = "=" & Left(m, Len(m) - 1)
    o = Left(o, Len(o) - 1)
    Cells(t, "O").Formula = "=" & Left(o, Len(o) - 1)
    p = Left(p, Len(p) - 1)
    Cells(t, "P").Formula = "=" & Left(p, Len(p) - 1)
    q = Left(q, Len(q) - 1)
    Cells(t, "Q").Formula = "=" & Left(q, Len(q) - 1)
    End With
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With
    End Sub

  11. #11
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hi John,

    The data is getting duplicated on every run.. its not deleting previous data..its appending

    Moreoever the Row with value "Rated ID" should not be changed..
    It should be always there itself after every conditioned row..

    That is on Row 14, Row 28, row 37, row 46, 55, 64, 73, 82, 91 should not be moved..

    Plz suggest

  12. #12
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hello John,

    I somehow got the issue why type mismatch error was coming.. i rectified it in the code you gave..

    Can you please help me for below

    (Hi John,

    The data is getting duplicated on every run.. its not deleting previous data..its appending

    Moreoever the Row with value "Rated ID" should not be changed..
    It should be always there itself after every conditioned row..

    That is on Row 14, Row 28, row 37, row 46, 55, 64, 73, 82, 91 should not be moved..

    Plz suggest)

  13. #13
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    If i run the code..

    It populates some data not all data..
    and after sometime it gives error..
    Type Mismatch at below line
    Case Is = 1

  14. #14
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Transfer data from Input sheet to output sheet on condition

    I would not work with a fix Template Sheet cause that will be a hell to maintain.
    I would suggest to Create the Whole Sheet by Code cause the Design for every Section is always the Same.

    My Approach would be sth like this.

    Edit: For the Header Thingy before row 13 you could create a template and start with a copy of that

    1. create a Settings Sheet with a table ID/Name where you write 1/1 TeraByte
    2. Sort the Data on the input Sheet by Column C
    3. Create Blank Sheet
    4. grab the name from your helper Table write it to row 13 and rated ID in 14
    5. Loop through the Input Sheet until id is not 1 anymore and copy the needed columns to the new sheet
    6. End the section on the new Sheet with Rated ID Sub Total
    7. do that for all entrys in the helper table.

    I dont have so much time today but i could take a look at it tomorrow if you don't get a solution

    kind regards Loki
    Last edited by LordLoki; 07-09-2015 at 09:35 AM.

  15. #15
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hello John,

    I managed to make the code in working condition.. Its done.. Thank you so much for this Appreciate your efforts & suggestions...


    Thanks Loki for suggestion.. Its solved with little trick...

  16. #16
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    HI John.... i had to comment some lines of code in order to make it working on my huge data...

    Everything is working fine but the formulaes are not getting updated..

    The Row having "Rated ID Sub Total" outputs formula as =SUM(#REF!)

    can u suggest some code which will rectify only the =SUM(#REF!) and consider the range of cells values to add above it..
    The formulea are in column (J, M, O, P, Q)

    thank you...

  17. #17
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Transfer data from Input sheet to output sheet on condition

    Can you repost the working code you are currently using? So I can see what you have commented out.

  18. #18
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Transfer data from Input sheet to output sheet on condition

    cause i already done it (had nothing to do in the Train) :D
    This code is more dynamic and the result looks better then your Template :D

    If you use it have fun with it if not maybe it helps others :D
    Put some more comments in and added sumifs Formula to the template Sheet

    Edited the Code and updated the File



    Sub test()
    Dim WsIn, WsOut, WsTmp, WsSet As Worksheet
    Dim WB As Workbook
    Dim lastrowSet, lastrowIn, lastrowOut As Long
    Dim actId As Integer
    Dim Startrow As Integer
    Dim rng As Range
    
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
    
    'Set Sheets
    Set WB = ThisWorkbook
    Set WsIn = WB.Sheets("Input")
    Set WsTmp = WB.Sheets("Template")
    Set WsSet = WB.Sheets("Settings")
    
    'Set Variables for Output Sheet
    Startrow = 14
    Spacebetween = 2
    Header1 = "Rated ID"
    idcol = 3
    Currentpoint = 2
    
    
    'Copy Template, Name it and set it to wsout
    WsTmp.Copy ThisWorkbook.Sheets(Sheets.Count)
    ActiveSheet.Name = "Output" & Sheets.Count
    Set WsOut = WB.Sheets("Output" & Sheets.Count)
    
    'Set variables for Last row of Setting and Input Sheet
    lastrowSet = WsSet.Range("A" & Rows.Count).End(xlUp).Row
    lastrowIn = WsIn.Range("A" & Rows.Count).End(xlUp).Row
    
    'Sort Input Sheet by Column C
    WsIn.Range("A1:U" & lastrowIn).Sort Key1:=WsIn.Range("C1"), Order1:=xlAscending, Header:=xlYes, orderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
    
    'Loop through the Settings List
    For i = 2 To lastrowSet
        'Store the actual ID in a var
        actId = WsSet.Cells(i, 1).Value
        'First run set last row to startrow -1
        If i = 2 Then
        lastrowOut = Startrow - 1
        Else
        'for all other runs add the defined space and update last row
        lastrowOut = lastrowOut + Spacebetween
        End If
        
        'start writing the name matching the id and make it Bold
        WsOut.Cells(lastrowOut + 1, 1).Value = WsSet.Cells(i, 2).Value
        WsOut.Cells(lastrowOut + 1, 1).Font.Bold = True
        'Write the Rated ID line after that and make it bold
        WsOut.Cells(lastrowOut + 2, 1).Value = Header1
        WsOut.Cells(lastrowOut + 2, 1).Font.Bold = True
        lastrowOut = WsOut.Range("A" & Rows.Count).End(xlUp).Row
        'save the startpoint of this section
        startpoint = lastrowOut + 1
        
                ' Start looping through the input list
                For j = Currentpoint To lastrowIn
                    'when the ID is Same as the current iD write the Line
                    If WsIn.Cells(j, idcol).Value = actId Then
                        WsOut.Cells(lastrowOut + 1, 1).Value = WsIn.Cells(j, 5).Value
                        WsOut.Cells(lastrowOut + 1, 2).Value = WsIn.Cells(j, 6).Value
                        WsOut.Cells(lastrowOut + 1, 3).Value = WsIn.Cells(j, 7).Value
                        WsOut.Cells(lastrowOut + 1, 4).Value = WsIn.Cells(j, 8).Value
                        WsOut.Cells(lastrowOut + 1, 5).Value = WsIn.Cells(j, 9).Value
                        WsOut.Cells(lastrowOut + 1, 6).Value = WsIn.Cells(j, 10).Value
                        WsOut.Cells(lastrowOut + 1, 7).Value = WsIn.Cells(j, 11).Value
                        WsOut.Cells(lastrowOut + 1, 8).Value = WsIn.Cells(j, 12).Value
                        WsOut.Cells(lastrowOut + 1, 9).Value = WsIn.Cells(j, 13).Value
                        WsOut.Cells(lastrowOut + 1, 10).Value = WsIn.Cells(j, 14).Value
                        WsOut.Cells(lastrowOut + 1, 11).Value = WsIn.Cells(j, 15).Value
                        WsOut.Cells(lastrowOut + 1, 12).Value = WsIn.Cells(j, 16).Value
                        WsOut.Cells(lastrowOut + 1, 13).Value = WsIn.Cells(j, 17).Value
                        WsOut.Cells(lastrowOut + 1, 14).Value = WsIn.Cells(j, 18).Value
                        WsOut.Cells(lastrowOut + 1, 15).Value = WsIn.Cells(j, 19).Value
                        WsOut.Cells(lastrowOut + 1, 16).Value = WsIn.Cells(j, 20).Value
                        WsOut.Cells(lastrowOut + 1, 17).Value = WsIn.Cells(j, 21).Value
                        'update last row
                        lastrowOut = WsOut.Range("A" & Rows.Count).End(xlUp).Row
                    Else
                        'if the ID does not match anymore write the Subtotal Line and make it bold
                        WsOut.Cells(lastrowOut + 1, 1).Value = "Rated ID Sub Total"
                        WsOut.Cells(lastrowOut + 1, 1).Font.Bold = True
                        'now add the formulas to the Subtotal Line
                        WsOut.Cells(lastrowOut + 1, 10).Formula = "=Sum(J" & startpoint & ":J" & lastrowOut & ")"
                        WsOut.Cells(lastrowOut + 1, 13).Formula = "=Sum(M" & startpoint & ":M" & lastrowOut & ")"
                        WsOut.Cells(lastrowOut + 1, 15).Formula = "=Sum(O" & startpoint & ":O" & lastrowOut & ")"
                        WsOut.Cells(lastrowOut + 1, 16).Formula = "=Sum(P" & startpoint & ":P" & lastrowOut & ")"
                        WsOut.Cells(lastrowOut + 1, 17).Formula = "=Sum(Q" & startpoint & ":Q" & lastrowOut & ")"
                        'Remember the row that we are in the input sheet for the next iteration
                        Currentpoint = j
                        Exit For
                    End If
                Next j
        'Before we go to the next iteration set the Lines and the Color for the Section
        Set rng = WsOut.Range("A" & startpoint & ":Q" & lastrowOut)
        rng.Interior.ColorIndex = 20
        With rng.Borders
            .LineStyle = xlContinuous
            .Color = vbBlack
            .Weight = xlThin
        End With
        Next i
    
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With
    
    End Sub
    Attached Files Attached Files
    Last edited by LordLoki; 07-09-2015 at 12:25 PM. Reason: Updated something

  19. #19
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hi Loki,

    The code you posted worked perfectly on huge data too.. thanks for it

    John thanks too you too.. because your code too helped me built different output sheets

    Thanks a Ton experts !!!!!



    Quote Originally Posted by LordLoki View Post
    cause i already done it (had nothing to do in the Train) :D
    This code is more dynamic and the result looks better then your Template :D

    If you use it have fun with it if not maybe it helps others :D
    Put some more comments in and added sumifs Formula to the template


    Sheet

    Edited the Code and updated the File



    Sub test()
    Dim WsIn, WsOut, WsTmp, WsSet As Worksheet
    Dim WB As Workbook
    Dim lastrowSet, lastrowIn, lastrowOut As Long
    Dim actId As Integer
    Dim Startrow As Integer
    Dim rng As Range
    
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
    
    'Set Sheets
    Set WB = ThisWorkbook
    Set WsIn = WB.Sheets("Input")
    Set WsTmp = WB.Sheets("Template")
    Set WsSet = WB.Sheets("Settings")
    
    'Set Variables for Output Sheet
    Startrow = 14
    Spacebetween = 2
    Header1 = "Rated ID"
    idcol = 3
    Currentpoint = 2
    
    
    'Copy Template, Name it and set it to wsout
    WsTmp.Copy ThisWorkbook.Sheets(Sheets.Count)
    ActiveSheet.Name = "Output" & Sheets.Count
    Set WsOut = WB.Sheets("Output" & Sheets.Count)
    
    'Set variables for Last row of Setting and Input Sheet
    lastrowSet = WsSet.Range("A" & Rows.Count).End(xlUp).Row
    lastrowIn = WsIn.Range("A" & Rows.Count).End(xlUp).Row
    
    'Sort Input Sheet by Column C
    WsIn.Range("A1:U" & lastrowIn).Sort Key1:=WsIn.Range("C1"), Order1:=xlAscending, Header:=xlYes, orderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
    
    'Loop through the Settings List
    For i = 2 To lastrowSet
        'Store the actual ID in a var
        actId = WsSet.Cells(i, 1).Value
        'First run set last row to startrow -1
        If i = 2 Then
        lastrowOut = Startrow - 1
        Else
        'for all other runs add the defined space and update last row
        lastrowOut = lastrowOut + Spacebetween
        End If
        
        'start writing the name matching the id and make it Bold
        WsOut.Cells(lastrowOut + 1, 1).Value = WsSet.Cells(i, 2).Value
        WsOut.Cells(lastrowOut + 1, 1).Font.Bold = True
        'Write the Rated ID line after that and make it bold
        WsOut.Cells(lastrowOut + 2, 1).Value = Header1
        WsOut.Cells(lastrowOut + 2, 1).Font.Bold = True
        lastrowOut = WsOut.Range("A" & Rows.Count).End(xlUp).Row
        'save the startpoint of this section
        startpoint = lastrowOut + 1
        
                ' Start looping through the input list
                For j = Currentpoint To lastrowIn
                    'when the ID is Same as the current iD write the Line
                    If WsIn.Cells(j, idcol).Value = actId Then
                        WsOut.Cells(lastrowOut + 1, 1).Value = WsIn.Cells(j, 5).Value
                        WsOut.Cells(lastrowOut + 1, 2).Value = WsIn.Cells(j, 6).Value
                        WsOut.Cells(lastrowOut + 1, 3).Value = WsIn.Cells(j, 7).Value
                        WsOut.Cells(lastrowOut + 1, 4).Value = WsIn.Cells(j, 8).Value
                        WsOut.Cells(lastrowOut + 1, 5).Value = WsIn.Cells(j, 9).Value
                        WsOut.Cells(lastrowOut + 1, 6).Value = WsIn.Cells(j, 10).Value
                        WsOut.Cells(lastrowOut + 1, 7).Value = WsIn.Cells(j, 11).Value
                        WsOut.Cells(lastrowOut + 1, 8).Value = WsIn.Cells(j, 12).Value
                        WsOut.Cells(lastrowOut + 1, 9).Value = WsIn.Cells(j, 13).Value
                        WsOut.Cells(lastrowOut + 1, 10).Value = WsIn.Cells(j, 14).Value
                        WsOut.Cells(lastrowOut + 1, 11).Value = WsIn.Cells(j, 15).Value
                        WsOut.Cells(lastrowOut + 1, 12).Value = WsIn.Cells(j, 16).Value
                        WsOut.Cells(lastrowOut + 1, 13).Value = WsIn.Cells(j, 17).Value
                        WsOut.Cells(lastrowOut + 1, 14).Value = WsIn.Cells(j, 18).Value
                        WsOut.Cells(lastrowOut + 1, 15).Value = WsIn.Cells(j, 19).Value
                        WsOut.Cells(lastrowOut + 1, 16).Value = WsIn.Cells(j, 20).Value
                        WsOut.Cells(lastrowOut + 1, 17).Value = WsIn.Cells(j, 21).Value
                        'update last row
                        lastrowOut = WsOut.Range("A" & Rows.Count).End(xlUp).Row
                    Else
                        'if the ID does not match anymore write the Subtotal Line and make it bold
                        WsOut.Cells(lastrowOut + 1, 1).Value = "Rated ID Sub Total"
                        WsOut.Cells(lastrowOut + 1, 1).Font.Bold = True
                        'now add the formulas to the Subtotal Line
                        WsOut.Cells(lastrowOut + 1, 10).Formula = "=Sum(J" & startpoint & ":J" & lastrowOut & ")"
                        WsOut.Cells(lastrowOut + 1, 13).Formula = "=Sum(M" & startpoint & ":M" & lastrowOut & ")"
                        WsOut.Cells(lastrowOut + 1, 15).Formula = "=Sum(O" & startpoint & ":O" & lastrowOut & ")"
                        WsOut.Cells(lastrowOut + 1, 16).Formula = "=Sum(P" & startpoint & ":P" & lastrowOut & ")"
                        WsOut.Cells(lastrowOut + 1, 17).Formula = "=Sum(Q" & startpoint & ":Q" & lastrowOut & ")"
                        'Remember the row that we are in the input sheet for the next iteration
                        Currentpoint = j
                        Exit For
                    End If
                Next j
        'Before we go to the next iteration set the Lines and the Color for the Section
        Set rng = WsOut.Range("A" & startpoint & ":Q" & lastrowOut)
        rng.Interior.ColorIndex = 20
        With rng.Borders
            .LineStyle = xlContinuous
            .Color = vbBlack
            .Weight = xlThin
        End With
        Next i
    
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With
    
    End Sub

  20. #20
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hi John, Below is the code with some commented.. bcoz i was getting error so i had to comment the last poarts of the code..
    I am successful in plotting all the data as per conditions with deletion of empty rows in it.. just left with formulaes to be plotted properly..

    Sub Parth007yy()
    Dim i As Long, t As Long
    Dim j As String, m As String, o As String, p As String, q As String
    Dim rcell As Range, u As Range, v As Range, w As Range, z As Range, z1 As Range, z2 As Range, z3 As Range, z4 As Range, z5 As Range
    Dim wsIn As Worksheet, wsOut As Worksheet
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
    Set wsIn = Sheets("Report Data")
    Set wsOut = Sheets("Holdings Report by Maturity")
    On Error Resume Next
    wsOut.Range("B13:B" & Range("A" & Rows.Count).End(9).Row).SpecialCells(xlCellTypeConstants, xlTextValues).EntireRow.Delete
    On Error GoTo 0
    With wsIn
    t = wsOut.Range("A" & Rows.Count).End(3).Row
    For i = .Range("C" & Rows.Count).End(3).Row To 2 Step -1
    Select Case .Cells(i, "C")
    
    Case Is = 1
    Set u = wsOut.Columns(1).Find("1 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not u Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(u.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set u = Nothing
    Case Is = 2
    Set v = wsOut.Columns(1).Find("2 MegaByte", LookIn:=xlValues, lookat:=xlPart)
        If Not v Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(v.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set v = Nothing
    Case Is = 3
    Set w = wsOut.Columns(1).Find("3 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not w Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(w.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set w = Nothing
    Case Is = 4
    Set z = wsOut.Columns(1).Find("4 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z = Nothing
    Case Is = 5
    Set z1 = wsOut.Columns(1).Find("5 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z1 Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z1.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z1 = Nothing
    Case Is = 6
    Set z2 = wsOut.Columns(1).Find("6 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z2 Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z2.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z2 = Nothing
    Case Is = 7
    Set z3 = wsOut.Columns(1).Find("7 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z3 Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z3.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z3 = Nothing
    Case Is = 8
    Set z4 = wsOut.Columns(1).Find("8 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z4 Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z4.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z4 = Nothing
    Case Is = 9
    Set z5 = wsOut.Columns(1).Find("9 TeraByte", LookIn:=xlValues, lookat:=xlPart)
        If Not z5 Is Nothing Then
                .Range(.Cells(i, "E"), .Cells(i, "U")).Copy
                wsOut.Cells(z5.Row, "A").Offset(1).EntireRow.Insert
        End If
            Set z5 = Nothing
    End Select
    Next i
    End With
    t = wsOut.Range("A" & Rows.Count).End(3).Row
    With wsOut
        For Each numrange In .Columns(10).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
        For Each numrange In .Columns(13).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
    For i = 15 To 17
        For Each numrange In .Columns(i).SpecialCells(xlConstants, xlNumbers).Areas
            sumaddr = numrange.Address(False, False)
            numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
            c = numrange.Count
        Next numrange
    Next i
    nodata:
    On Error Resume Next
    
    .Range(.Cells(13, 1), .Cells(t, 1)).SpecialCells(4).EntireRow.Delete
    'Exit Sub
    'On Error GoTo 0
    'j = ""
    'm = ""
    'o = ""
    'p = ""
    'q = ""
    'For Each rcell In .Range("A13:A10096") ' & .Range("A" & Rows.Count).End(3).Row)
    '    If rcell Like "*Byte Total*" Then
    '        .Cells(rcell.Row - 1, "J").Formula = .Cells(rcell.Row - 2, "J").Formula
    '        .Cells(rcell.Row, "J").Formula = .Cells(rcell.Row - 1, "J").Formula
    '        j = j & "J" & rcell.Row & "+"
    '        j = j
    '        .Cells(rcell.Row - 1, "M").Formula = .Cells(rcell.Row - 2, "M").Formula
    '        .Cells(rcell.Row, "M").Formula = .Cells(rcell.Row - 1, "M").Formula
    '        m = m & "M" & rcell.Row & "+"
    '        m = m
    '        .Cells(rcell.Row - 1, "O").Formula = .Cells(rcell.Row - 2, "O").Formula
    '        .Cells(rcell.Row, "O").Formula = .Cells(rcell.Row - 1, "O").Formula
    '        o = o & "O" & rcell.Row & "+"
    '        o = o
    '        .Cells(rcell.Row - 1, "P").Formula = .Cells(rcell.Row - 2, "P").Formula
    '        .Cells(rcell.Row, "P").Formula = .Cells(rcell.Row - 1, "P").Formula
    '        p = p & "P" & rcell.Row & "+"
    '        p = p
    '        .Cells(rcell.Row - 1, "Q").Formula = .Cells(rcell.Row - 2, "Q").Formula
    '        .Cells(rcell.Row, "Q").Formula = .Cells(rcell.Row - 1, "Q").Formula
    '        q = q & "Q" & rcell.Row & "+"
    '        q = q
    '    End If
    'Next rcell
    't = wsOut.Range("A" & Rows.Count).End(3).Row
    'j = Left(j, Len(j) - 1)
    'Cells(t, "J").Formula = "=" & Left(j, Len(j) - 1)
    'm = Left(m, Len(m) - 1)
    'Cells(t, "M").Formula = "=" & Left(m, Len(m) - 1)
    'o = Left(o, Len(o) - 1)
    'Cells(t, "O").Formula = "=" & Left(o, Len(o) - 1)
    'p = Left(p, Len(p) - 1)
    'Cells(t, "P").Formula = "=" & Left(p, Len(p) - 1)
    'q = Left(q, Len(q) - 1)
    'Cells(t, "Q").Formula = "=" & Left(q, Len(q) - 1)
    End With
    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With
    End Sub

    The formulea are in column (J, M, O, P, Q)
    & i am getting =SUM(#REF!)


    Dear Loki, thanks for the code.. your code also worked with the data in Input sheet.. but when i actually put all original Input data in sheet which is more than 10000 it does not pick all correct data in Output sheet.. & i have to keep the format consistent coz the sheet is just one part of macro.. more macro gets executed on it.. so cant move or delete anything unless necessary.. too much of confusion on the sheet.. coz fata is around 20,000 to 50,000
    Last edited by Parth007; 07-10-2015 at 04:01 AM.

  21. #21
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hi Loki,


    I Sorted Settings sheet before running Macro..

    It executes well IF column have Only Integers as (1,2,3,4,5,6..)
    or column have only Characters values as (A,B,CC,D,F,E,R,MM)


    But for IF columns have values Numbers+ Characters+AplhaNumeric as (0,A1,A2,A3,NA,NR,WR,AA1,AA2,AA3,AAA,BA1,BAA1,BAA2,BAA3) it only populates data for A1, A2, A3 rests it fails & do not popualte anything after that... Please suggest
    Last edited by Parth007; 07-10-2015 at 07:07 AM.

  22. #22
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Transfer data from Input sheet to output sheet on condition

    Hi Parth,

    I found one thing that needs to be changed the last group did not get a Subtotal. therefore the Sum in the Top is not correct.
    I also changed the actid variable to string that works for all cenarios.
    Now it should work fine i testet with 100k input Data and got a perfekt result after 4 Minutes

    Greets
    Loki
    Attached Files Attached Files

  23. #23
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hi Loki, The issue remains same... .. It does not capture the Last sub total..
    Moreover it populate wrong data for first conditions

  24. #24
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Transfer data from Input sheet to output sheet on condition

    For me it works perfekt now.
    Did you adjust the Settings sheet when you try it with the Real Data?

  25. #25
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    If you execute this...
    We only get data for A1, A2, A3.. thats it.. i am puzzled what is stopping other to populate

    If this works.. i am done
    Attached Files Attached Files

  26. #26
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Transfer data from Input sheet to output sheet on condition

    Yeah figured it out.
    Sample Data was sorted nicely from 1 to 9 so that worked well.

    Is the order of items in the output sheet important?
    Then it will take a bit longer to fix.
    If the order is not of importance its fixed easier

    Greets
    Loki

  27. #27
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Transfer data from Input sheet to output sheet on condition

    another reason is that your data is upper and lower case mixed. in the Settings you did not set that up accordingly.
    If for you "AAA" is the same as "aaa" tell me than i can compare the ids uppercase

  28. #28
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hi Loki,

    The order of the data is not that important as of now.. More over if you can make everything in Uppercase even that will do
    Moreover if we add a new condition in the Settings sheet the subtotal does not gets captured for last condition...

    Please suggest Thanks You

  29. #29
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hello Loki, Even though if Sub total is not plotted that will also do.. just need the data to be in for each conditions..

  30. #30
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Transfer data from Input sheet to output sheet on condition

    Hi Parth,

    Did change the Process a bit.
    I create a backup of the Input
    Then i loop through the Input Sheet and delete the Cells that are passed to the Output
    Testet with a mix of Identifiers (0,AB and AZ6) and it worked well.

    Check with your Real data and report back
    Attached Files Attached Files

  31. #31
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Transfer data from Input sheet to output sheet on condition

    Hi Loki,

    I debugged, rectified it.. Bingo..

    Its Bang on Target... worked superbly.. Would write a seperate code to delete the Backup Input sheet.. as it will be no longer required..

    Thanks a Ton Loki
    Last edited by Parth007; 07-13-2015 at 05:58 AM.

  32. #32
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Transfer data from Input sheet to output sheet on condition

    You are welcome always happy if i can help

    for the backup sheet you can just not generate it at all then you don't have to delete it :D
    its just a backup the code does not refer to it at all.

    greets
    Loki
    Last edited by LordLoki; 07-13-2015 at 08:24 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Issue regarding recorded Macro to transfer data from Input sheet to Storage sheet
    By Hirad001 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-29-2015, 04:26 PM
  2. [SOLVED] Desire data segregate from “input” sheet to “output “sheet
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2014, 07:10 AM
  3. [SOLVED] Desire data extract from the sheet “input” to the sheet “output”
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-24-2014, 02:19 PM
  4. How to transfer data from a daily input sheet to a separate monthly total sheet
    By Jcooper71 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2014, 02:37 PM
  5. Populate Output sheet based on input data and lookup condition
    By Cool\m/ in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-10-2013, 04:45 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1