+ Reply to Thread
Results 1 to 26 of 26

End data to column G

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    End data to column G

    Look at what i have done manually

    Shift data to next row , should not exceed column G

    Data A1:M20

    See sample expected to A22:G44

    Macro to work at 44,444 rows

    Note : Push data to next line starting column C if data extends column G
    Attached Files Attached Files

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: End data to column G

    Sub J3v16()
    Dim Data, Temp, i As Long, ii As Long, x As Long, xx As Long
    With Cells(1).CurrentRegion
        Data = .Value
        ReDim Temp(1 To UBound(Data, 1) + UBound(Data, 2), 1 To 7)
        For i = 1 To UBound(Data, 1)
            x = x + 1: xx = 0
            For ii = 1 To UBound(Data, 2)
                If Data(i, ii) <> "" Then
                    xx = xx + 1
                    If xx = 8 Then x = x + 1: xx = 3
                    Temp(x, xx) = Data(i, ii)
                End If
            Next ii
        Next i
        .ClearContents
        .Resize(x, 7) = Temp
    End With
    End Sub
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: End data to column G

    Try:
    PHP Code: 
    Option Explicit
    Sub test
    ()
    Dim lr&, i&, j&, r&, k&, c&, t&, rngarr(1 To 100001 To 7)
    rng Range("A1").CurrentRegion.Value
    For 1 To UBound(rng)
        
    1
        arr
    (r1) = rng(i1): arr(r2) = rng(i2)
        For 
    3 To UBound(rng2)
            If 
    rng(ij) <> "" Then
                t 
    Int((3) / 5)
                
    = ((3Mod 5) + 3
                arr
    (tc) = rng(ij)
            
    End If
        
    Next
    Next
    Range
    ("A1:ZZ100000").ClearContents
    Range
    ("A1").Resize(r7).Value arr
    End Sub 
    Quang PT

  4. #4
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    Thank u sintek and bebo21999

    Will ask for an add on the macro , at column H i need to to count na alpha

    See manually plugged results
    Attached Files Attached Files

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: End data to column G

    I don't understand how you got those results...Why is H14, H16, H17 blank?

    If this below is actual result required...

    Untitled.png

    Then this amendment will work...
    Sub J3v16()
    Dim Data, Temp, i As Long, ii As Long, x As Long, xx As Long
    With Cells(1).CurrentRegion
        Data = .Value
        ReDim Temp(1 To UBound(Data, 1) + UBound(Data, 2), 1 To 8)
        For i = 1 To UBound(Data, 1)
            x = x + 1: xx = 0
            For ii = 1 To UBound(Data, 2)
                If Data(i, ii) <> "" Then
                    xx = xx + 1
                    If xx = 8 Then x = x + 1: xx = 3
                    Temp(x, xx) = Data(i, ii): Temp(x, 8) = xx - 2
                End If
            Next ii
        Next i
        .ClearContents
        .Resize(x, 8) = Temp
    End With
    End Sub
    Last edited by sintek; 09-13-2022 at 05:18 AM.

  6. #6
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    for AEINRST it is 5 + 5 + 1 that is 11

    It should plug 11 at row 15 and leave blank at row 16 and 17
    Last edited by makinmomb; 09-13-2022 at 05:32 AM. Reason: detailed

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,621

    Re: End data to column G

    Sub test()
        Dim a, b, i As Long, ii As Long, temp As Long, n As Long, t As Long
        a = Sheets(1).Cells(1).CurrentRegion.Value
        ReDim b(1 To UBound(a, 1) * (UBound(a, 2) - 3), 1 To 8)
        For i = 1 To UBound(a, 1)
            n = n + 1: temp = n
            For ii = 1 To 2
                b(n, ii) = a(i, ii)
            Next
            t = 3
            For ii = 3 To UBound(a, 2)
                If a(i, ii) = "" Then Exit For
                b(temp, 8) = b(temp, 8) + 1
                b(n, t) = a(i, ii)
                t = t + 1
                If t > 7 Then n = n + 1: t = 3
            Next
        Next
        Sheets.Add.Cells(1).Resize(n, 8) = b
    End Sub

  8. #8
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    It is blank as AEINSTR is a set of 11 words 5 each on two rows and 1 additional

  9. #9
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    Jindon yours too does not do 11 for h16

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,621

    Re: End data to column G

    No idea why you want it 9 instead 11, so I'm out.

  11. #11
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    Jindon

    These are 11

    ANESTRI ANTSIER NASTIER RATINES RESIANT
    RETAINS RETINAS RETSINA STAINER STARNIE
    STEARIN

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: End data to column G

    Sub J3v16()
    Dim Data, Temp, i As Long, ii As Long, x As Long, xx As Long, xxx As Long
    With Cells(1).CurrentRegion
        Data = .Value
        ReDim Temp(1 To UBound(Data, 1) + UBound(Data, 2), 1 To 8)
        For i = 1 To UBound(Data, 1)
            x = x + 1: xx = 0: xxx = -2
            For ii = 1 To UBound(Data, 2)
                If Data(i, ii) <> "" Then
                    xx = xx + 1: xxx = xxx + 1
                    If xx = 8 Then x = x + 1: xx = 3
                    Temp(x, xx) = Data(i, ii)
                End If
            Next ii
            Temp(x, 8) = xxx
        Next i
        .ClearContents
        .Resize(x, 8) = Temp
    End With
    End Sub

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,621

    Re: End data to column G

    Sub test()
        Dim a, b, i As Long, ii As Long, temp As Long, n As Long, t As Long, x As Long
        a = Sheets("sheet1").Cells(1).CurrentRegion.Value
        ReDim b(1 To UBound(a, 1) * (UBound(a, 2) - 3), 1 To 8)
        For i = 1 To UBound(a, 1)
            n = n + 1: temp = n
            For ii = 1 To 2
                b(n, ii) = a(i, ii)
            Next
            t = 3: x = 0
            For ii = 3 To UBound(a, 2)
                If a(i, ii) = "" Then Exit For
                x = x + 1
                b(n, t) = a(i, ii)
                t = t + 1
                If t > 7 Then n = n + 1: t = 3
            Next
            b(temp + Fix((n - temp) / 2), 8) = x
        Next
        Sheets.Add.Cells(1).Resize(n, 8) = b
    End Sub
    Last edited by jindon; 09-13-2022 at 06:26 AM. Reason: Fixed a bug

  14. #14
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    Run Time Error 9 on SIntek Macro on real data which is 44,000 rows
    Jindon your macro is not working on 44,ooo rows and pours on results of test data given
    Last edited by makinmomb; 09-13-2022 at 07:11 AM. Reason: 44000

  15. #15
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: End data to column G

    Change red + to *

    ReDim Temp(1 To UBound(Data, 1) + UBound(Data, 2), 1 To 8)

  16. #16
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    Sintex please paste code again so we can close thread , getting compile error

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,621

    Re: End data to column G

    Tried 80000 rows with 30 cols data and no error.
    Sub test()
        Dim a, b, i As Long, ii As Long, temp As Long, n As Long, t As Long, x As Long
        a = Sheets("sheet1").Cells(1).CurrentRegion.Value
        ReDim b(1 To UBound(a, 1) * (UBound(a, 2) - 3), 1 To 8)
        For i = 1 To UBound(a, 1)
            n = n + 1: temp = n
            For ii = 1 To 2
                b(n, ii) = a(i, ii)
            Next
            t = 2: x = 0
            For ii = 3 To UBound(a, 2)
                If a(i, ii) = "" Then Exit For
                x = x + 1: t = t + 1
                If t > 7 Then n = n + 1: t = 3
                b(n, t) = a(i, ii)
            Next
            b(temp + Fix((n - temp) / 2), 8) = x
        Next
        Sheets("sheet2").Cells(1).Resize(n, 8) = b
    End Sub

  18. #18
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    Find attached file with added details for upto 5oo rows to see if it works
    Attached Files Attached Files

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,621

    Re: End data to column G

    DO NOT MIX MY CODE WITH OTHERS.
    Sub test()
        Dim a, b, i As Long, ii As Long, temp As Long, n As Long, t As Long, x As Long
        a = Sheets("sheet1").Cells(1).CurrentRegion.Value
        ReDim b(1 To UBound(a, 1) * (UBound(a, 2) - 3), 1 To 8)
        For i = 1 To UBound(a, 1)
            n = n + 1: temp = n
            For ii = 1 To 2
                b(n, ii) = a(i, ii)
            Next
            t = 2: x = 0
            For ii = 3 To UBound(a, 2)
                If a(i, ii) = "" Then Exit For
                x = x + 1: t = t + 1
                If t > 7 Then n = n + 1: t = 3
                b(n, t) = a(i, ii)
            Next
            b(temp + Fix((n - temp) / 2), 8) = x
        Next
        Sheets("sheet2").Cells(1).Resize(n, 8) = b
    End Sub

  20. #20
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    Not working here are the results of the macro your jindon

    Find attached
    Attached Files Attached Files

  21. #21
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: End data to column G

    Have you tried mine? with that small change of + to *
    Attached Files Attached Files

  22. #22
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,621

    Re: End data to column G

    Really hoepless...

  23. #23
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    Thank u Jindon bionic it pushed all that mass data at 1 second ,crazy

  24. #24
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    What is the meaning of binary macro , i have always saved files as Macro enabled , this binary thingi is my first time

  25. #25
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    Sintek yours working as quick as Jindon , button Jindon is faster by another 3 seconds as his got that run button

  26. #26
    Forum Contributor
    Join Date
    01-04-2014
    Location
    East Africa
    MS-Off Ver
    MS OFFICE 2019 PRO
    Posts
    3,618

    Re: End data to column G

    I have collected both versions including that of Sintek , it is as good as that of Jindon

+ 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] Rank by Column Q data first, then by Column L data, then by Column K data to break ties
    By clark402 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-08-2021, 01:27 AM
  2. [SOLVED] Extract Data in Column B and Column C Into Column E and F Based on Condition in Column D
    By bjnockle in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-10-2021, 12:18 PM
  3. Replies: 4
    Last Post: 05-22-2020, 04:01 AM
  4. Replies: 4
    Last Post: 12-09-2019, 07:30 PM
  5. [SOLVED] Column A Data compared to Column B and Corresponding Data in Column A shown in Column C???
    By EverCheck in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-24-2015, 11:45 AM
  6. Macro to copy and paste special values for column data and filter column data
    By ascottbag in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-10-2012, 02:15 PM
  7. Replies: 3
    Last Post: 02-08-2010, 06:18 PM

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