+ Reply to Thread
Results 1 to 7 of 7

IF formula true THEN move to next row

Hybrid View

  1. #1
    Registered User
    Join Date
    12-27-2012
    Location
    Cluj-Napoca
    MS-Off Ver
    Excel 2010
    Posts
    14

    IF formula true THEN move to next row

    I have a table with 131 columns and 4000 rows. I need in a different sheet to make a tabel with 3 raws:

    original tabel has row A as an name(internal number composed of leters and/or digits) and the rest of rows are warehouse names; under warehouse names are numbers .

    internal number warehouse1 warehouse2 warehouse3
    abc 1 0 1
    def 0 2 0

    Using the example above I need to make a new table(in a new sheet) that will collect the data like this:

    Internal number Location Sales
    abc ware1 1
    abc ware3 1
    def ware2 2

    I tried a lot of formulas but none did help me prepare what i want. Anyone got an ideea? I attached an bigger example so anyone who tries to help me can do that in that table.
    Attached Files Attached Files

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: IF formula true THEN move to next row

    here' one way

    Sub abc()
     Dim a, b, i As Long, ii As Long, n As Long
     
     With Worksheets("sheet1")
        a = .Range("I1").CurrentRegion
     
        ReDim b(1 To Rows.Count, 1 To 3)
        
        For i = 2 To UBound(a, 1)
           For ii = 2 To UBound(a, 2)
               If Not IsEmpty(a(i, ii)) And a(i, ii) > 0 Then
                   n = n + 1
                   b(n, 1) = a(i, 1)
                   b(n, 2) = a(1, ii)
                   b(n, 3) = a(i, ii)
               End If
           Next
        Next
        .Cells(6, "c").Resize(n, 3) = b
     End With
    End Sub
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    12-27-2012
    Location
    Cluj-Napoca
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: IF formula true THEN move to next row

    your formula is what i need.
    how can i bring the new data to a new sheet? so that my first table remains untouched
    Last edited by zepelin; 12-28-2012 at 05:02 AM.

  4. #4
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: IF formula true THEN move to next row

    Hi zepelin

    Will the INDEX & MATCH achieve those results! In E6 & copy down, adjust the ranges to suit your needs.
    Formula: copy to clipboard
    =INDEX($J$2:$M$15,MATCH(C26,$I$2:$I$15,0),MATCH(D26,$J$1:$M$1,0))


    Kevin

  5. #5
    Registered User
    Join Date
    12-27-2012
    Location
    Cluj-Napoca
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: IF formula true THEN move to next row

    this is the table
    Attached Files Attached Files

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: IF formula true THEN move to next row

    This should do it

    Sub abc()
     Dim a, b, i As Long, ii As Long, n As Long
     
     With Worksheets("sheet1")
        a = .Range("a1").CurrentRegion
     End With
     ReDim b(1 To Rows.Count, 1 To 3)
    
     For i = 2 To UBound(a, 1)
        For ii = 2 To UBound(a, 2)
           If Not IsEmpty(a(i, ii)) And a(i, ii) > 0 Then
               n = n + 1
               b(n, 1) = a(i, 1)
               b(n, 2) = a(1, ii)
               b(n, 3) = a(i, ii)
           End If
        Next
     Next
     With Worksheets("sheet2")
        .Cells(1, "a").Resize(n, 3) = b
     End With
    End Sub

  7. #7
    Registered User
    Join Date
    12-27-2012
    Location
    Cluj-Napoca
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: IF formula true THEN move to next row

    Great work.

    Thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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