Results 1 to 10 of 24

Thread: Move values in rows at the end of the preceding row *SOLVED*

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member xladept's Avatar
    Join Date
    May 2016
    Posts
    12
    Rep Power
    0
    I think this gets the rogues:

    Code:
    Sub NormanXLFox(): Dim wa As Worksheet, wb As Worksheet, r As Long, B
    Set wb = Sheets("Before"): Set wa = Sheets("After")
    B = wb.UsedRange: wb.UsedRange.AutoFilter 1, "=2018*"
    For r = 2 To Range("A" & Rows.Count).End(xlUp).Row + 1
    If Rows(r).RowHeight = 0 And Rows(r - 1).RowHeight <> 0 And _
    IsNumeric(Left(Range("A" & r), 1)) Then
    Range("A" & r - 1) = Range("A" & r - 1) & "," & Range("A" & r)
    End If: Next r
    wb.UsedRange.Offset(1).SpecialCells(xlCellTypeVisible).Copy _
                wa.Cells(1, 1)
    wa.UsedRange.Replace ",,", ","
    wb.UsedRange.AutoFilter: wb.UsedRange = B
    End Sub
    Last edited by xladept; 01-01-2019 at 02:30 AM.
    You can't do one thing.

    Orrin

  2. #2
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    Quote Originally Posted by xladept View Post
    I think this gets the rogues:
    It certainly does/ ( did the second time around) , you smug g_t , you had to show us how to do it properly didn't you :-)
    I'm going to light a firework now, see you next year…


    Code:
    Sub NormanXLFoxAfterAThink() ' 10.03pm
    Dim wa As Worksheet, wb As Worksheet, r As Long
    Set wb = Sheets("Before"): Set wa = Sheets("AfterAThink")
     wb.UsedRange.AutoFilter 1, "=2018*"
     wb.UsedRange.Offset(1).SpecialCells(xlCellTypeVisible).Copy wa.Cells(1, 1)
        For r = 2 To Range("A" & Rows.Count).End(xlUp).Row
            If Rows(r).RowHeight = 0 And Rows(r - 1).RowHeight <> 0 And _
             IsNumeric(Left(Range("A" & r), 1)) Then
             Range("A" & r - 1) = Range("A" & r - 1) & "," & Range("A" & r)
            End If
        Next r
    wb.UsedRange.AutoFilter
    End Sub
    
    Sub NormanXLFoxAfterASecondThink() ' 10.30pm
    Dim wa As Worksheet, wb As Worksheet, r As Long
     Set wb = Sheets("Before"): Set wa = Sheets("AfterASecondThink")
     wb.Activate
            wb.UsedRange.AutoFilter 1, "=2018*"
        For r = 2 To Range("A" & Rows.Count).End(xlUp).Row + 1
            If Rows(r).RowHeight = 0 And Rows(r - 1).RowHeight <> 0 And _
             IsNumeric(Left(Range("A" & r), 1)) Then
             Range("A" & r - 1) = Range("A" & r - 1) & "," & Range("A" & r)
            End If
        Next r
     wb.UsedRange.Offset(1).SpecialCells(xlCellTypeVisible).Copy Destination:=wa.Cells(1, 1)
     wa.UsedRange.Replace ",,", ","
     wb.UsedRange.AutoFilter
    End Sub
    _____ Workbook: Data Sample.xlsm ( Using Excel 2007 32 bit )
    Row\Col
    A
    1
    2018, 1, 90515, 10024515, G9, SBlabla (HQ), CHE, BLABLA, blabla, 10012098, 12003.5
    2
    2018, 1, 90629, 10022334, P3, BLABLA blabla (blablabla), CHE, BLABLA,blabla, 10033609, 13941.72
    3
    2018, 1, 90709, 10020009, P4, Blabla og Blalala (NY), CHE, Blabla,Bla-ah,10006098, 15392.64
    4
    2018, 1, 90765, 10012123, P4, Ch of Blabla(Blabla of Blabla), CHE, BLA-BLA,Bla Blabla,10005678, 16231.7
    5
    2018, 1, 90712, 10022908, P4, Snr BLA Off (Strat BLa, BLA), CHE, BLABLA,Bla BLabla, 10023234,14900.28
    6
    2018, 1, 90919, 10020984, P2, Ass BLA Balbla, CHE, BLA,Blabla, 10033098, 10486.33
    7
    2018, 1, 95706, 10023098, NB, Assc BLA Blabal (LatBLAa), BLA, BLABLABLA,Blabla, 10034318,7566.31
    8
    2018, 1, 95716, 10018763, NA, Asst BLA Off (Blabla & Multi-BLa), BLA, BLA,Bla, 10097776, 8607.96
    9
    2018, 1, 99716, 10026132, G5, Snr BLA Asst (Bla Blabla), BLA, BLABLA,bla BLa, 18767043, 5477.44
    10
    2018, 1, 99716, 10016545, G6, Blabla Blabla (BLA), BLA, BLABLABLA,Blabla, 1097029,5325.3
    Worksheet: AfterASecondThink
    Attached Files Attached Files
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    KILL A MODERATOR!!

Similar Threads

  1. Replies: 8
    Last Post: 09-04-2014, 02:45 AM
  2. vba to move data from a row to a column
    By RobertCordrey in forum Excel Help
    Replies: 3
    Last Post: 03-03-2014, 08:20 AM
  3. Skip empty row and fetch values from other rows
    By dhivya.enjoy in forum Excel Help
    Replies: 1
    Last Post: 11-08-2013, 07:44 PM
  4. Move data from rows into columns for every unique value
    By mahmoud-lee in forum Excel Help
    Replies: 4
    Last Post: 06-13-2013, 03:02 AM
  5. Move or Copy Duplicate Rows to Difference Sheet
    By Vgabond in forum Excel Help
    Replies: 3
    Last Post: 12-08-2012, 12:33 PM

Tags for this Thread

Posting Permissions

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