Results 1 to 10 of 604

Thread: Appendix-Thread-Evaluate-Range-(-Codes-for-other-Threads-HTML-Tables-etc-)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    Reduced data

    _____ Workbook: VBA row to cell1 reduced data.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    1
    2
    234. *….Keywrod1:
    2021-2022***
    3
    4
    This also
    text channel.
    5
    Digital to
    connect communication.
    6
    7
    8
    Digital to
    connect communication.
    This also
    text channel.
    9
    10
    Keywrod1:
    11
    Keyword2: QWERTY
    12
    13
    14
    2344. ….Keywrod1: *** 2020-2021
    digital information
    digital information
    15
    16
    Digital marketing: =
    also to
    connect communication.
    This also
    text channel.
    17
    Digital to
    connect communication.
    18
    19
    Digital to
    connect communication.
    This also
    text channel.
    20
    Digital to
    connect communication.
    This also
    text channel.
    21
    Keywrod1: *** 2020-2021
    22
    Digital to
    connect communication.
    This also
    text channel.
    23
    Keyword2
    24
    Worksheet: InputSheet1
    Code:
    "234. *….Keywrod1: 
    2021-2022***"
    
    "This also 
    text channel."
    "Digital to 
    connect communication. "
    
    
    "Digital to 
    connect communication. 
    This also 
    text channel."
    
    Keywrod1: 
    Keyword2:  QWERTY
    
    
    "2344. ….Keywrod1: *** 2020-2021
    digital information
    digital information"
    
    "Digital marketing: =
    also to 
    connect communication. 
    This also 
    text channel."
    "Digital to 
    connect communication. "
    
    "Digital to 
    connect communication. 
    This also 
    text channel."
    "Digital to 
    connect communication. 
    This also 
    text channel."
    Keywrod1: *** 2020-2021
    "Digital to 
    connect communication. 
    This also 
    text channel."
    Keyword2




    Output
    _____ Workbook: VBA row to cell1 reduced data.xls ( Using Excel 2007 32 bit )
    Row\Col
    A
    2
    234. *….Keywrod1:
    2021-2022***

    This also
    text channel.
    Digital to
    connect communication.


    Digital to
    connect communication.
    This also
    text channel.

    Keywrod1:
    Keyword2: QWERTY
    3
    2344. ….Keywrod1: *** 2020-2021
    digital information
    digital information

    Digital marketing: =
    also to
    connect communication.
    This also
    text channel.
    Digital to
    connect communication.

    Digital to
    connect communication.
    This also
    text channel.
    Digital to
    connect communication.
    This also
    text channel.
    Keywrod1: *** 2020-2021
    Digital to
    connect communication.
    This also
    text channel.
    Keyword2
    Worksheet: Sheet2
    Copy/ Paste
    Code:
    "234. *….Keywrod1: 
    2021-2022***
    
    This also 
    text channel.
    Digital to 
    connect communication. 
    
    
    Digital to 
    connect communication. 
    This also 
    text channel.
    
    Keywrod1: 
    Keyword2:  QWERTY"
    "2344. ….Keywrod1: *** 2020-2021
    digital information
    digital information
    
    Digital marketing: =
    also to 
    connect communication. 
    This also 
    text channel.
    Digital to 
    connect communication. 
    
    Digital to 
    connect communication. 
    This also 
    text channel.
    Digital to 
    connect communication. 
    This also 
    text channel.
    Keywrod1: *** 2020-2021
    Digital to 
    connect communication. 
    This also 
    text channel.
    Keyword2"
    Copy text from cel or cel .Value
    Code:
    234. *….Keywrod1: 
    2021-2022***
    
    This also 
    text channel.
    Digital to 
    connect communication. 
    
    
    Digital to 
    connect communication. 
    This also 
    text channel.
    
    Keywrod1: 
    Keyword2:  QWERTY
    Code:
    2344. ….Keywrod1: *** 2020-2021
    digital information
    digital information
    
    Digital marketing: =
    also to 
    connect communication. 
    This also 
    text channel.
    Digital to 
    connect communication. 
    
    Digital to 
    connect communication. 
    This also 
    text channel.
    Digital to 
    connect communication. 
    This also 
    text channel.
    Keywrod1: *** 2020-2021
    Digital to 
    connect communication. 
    This also 
    text channel.
    Keyword2




    VBA row to cell1 reduced data.xls : https://app.box.com/s/qne60lkrfp30d50w444gedzjg6b7nyat
    ….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!!

  2. #2
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    Second solution, Solution 2 for this thread
    https://excelfox.com/forum/showthrea...cell-in-sheet2




    Code:
    Sub ConsolidateLines_Solution2() '   https://excelfox.com/forum/showthread.php/2815-Copy-data-from-multiple-rows-between-two-keyword-and-paste-the-data-in-row(s)-of-single-cell-in-sheet2
    Rem 0 worksheets data info
    Dim Ws1 As Worksheet, Ws2 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets.Item(1): Set Ws2 = ThisWorkbook.Worksheets.Item(2)
    Dim Lr As Long: Let Lr = Ws1.Range("A" & Ws1.Rows.Count & "").End(xlUp).Row
     
    Rem 3 Initial to get started, finding first start point of text we want
     Dim RngStt As Range ' This will be the cell with the first  Keywrod1
      Set RngStt = Ws1.Range("A1:A" & Lr & "").Find(What:="Keywrod1", After:=Ws1.Range("A" & Lr & ""), LookIn:=xlValues, LookAt:=xlPart, Searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=True)
    Rem 4 main text manipulation
    '4a)
        Do While Not RngStt Is Nothing ' This the main outer loop will terminate if we find no new first keyword #####
        Dim RngStp As Range ' This willl be the cell with the next  Keyword2
         Set RngStp = Ws1.Range("A" & RngStt.Row + 1 & ":A" & Lr & "").Find(What:="Keyword2", After:=Ws1.Range("A" & RngStt.Row + 1 & ""), LookIn:=xlValues, LookAt:=xlPart, Searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=True)
            If RngStp Is Nothing Then Exit Do  ' This is for the case of if there is no Keyword2  after  a found  Keywrod1
    '4b)
        Dim Rw As Long
            For Rw = RngStt.Row To RngStp.Row Step 1 ' We loop through the cells in between and including the cells with  Keywrod1  and  keyword2
            Dim NewCelStr As String ' This is used to build the string for a new cell
             Let NewCelStr = NewCelStr & Ws1.Range("A" & Rw & "").Value2 & vbLf  ' Add the next cell text followed by a new line character
            Next Rw
         Let NewCelStr = Left(NewCelStr, Len(NewCelStr) - 1)
        Dim Lr2 As Long: Let Lr2 = Ws2.Range("A" & Ws2.Rows.Count & "").End(xlUp).Row
         Let Ws2.Range("A" & Lr2 + 1 & "").Value = NewCelStr
    '4c(ii)
         Let NewCelStr = ""
         Set RngStt = Ws1.Range("A" & RngStp.Row & ":A" & Lr + 1 & "").Find(What:="Keywrod1", After:=Ws1.Range("A" & RngStp.Row + 1 & ""), LookIn:=xlValues, LookAt:=xlPart, Searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:=True)
        Loop ' While Not RngStt = Nothing '  ### Main outer loop terminates when main text manipulation is finished ##
     
     
     Ws2.Columns(1).WrapText = False
    End Sub
    ….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. Testing Concatenating with styles
    By DocAElstein in forum Test Area
    Replies: 2
    Last Post: 12-20-2020, 02:49 AM
  2. testing
    By Jewano in forum Test Area
    Replies: 7
    Last Post: 12-05-2020, 03:31 AM
  3. Replies: 18
    Last Post: 03-17-2019, 06:10 PM
  4. Concatenating your Balls
    By DocAElstein in forum Excel Help
    Replies: 26
    Last Post: 10-13-2014, 02:07 PM
  5. Replies: 1
    Last Post: 12-04-2012, 08:56 AM

Posting Permissions

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