+ Reply to Thread
Results 1 to 9 of 9

Macro to rename cell content based on the starting character until found same character

Hybrid View

  1. #1
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Macro to rename cell content based on the starting character until found same characte

    1 mistake in previus, this should be the good one

    Sub Leo()
    Dim st As Range, en As Range, lr As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row - 1
    r = 1
    With Sheets("sheet1")
        Set st = .Cells.Find(what:="From Store:", after:=Range("A" & r), LookIn:=xlValues, LookAt:= _
        xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False)
        Range("A" & st.Row, "E" & st.Row).Delete shift:=xlUp
        Set st = .Cells.Find(what:="Total from:", after:=Range("A" & r), LookIn:=xlValues, LookAt:= _
        xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False)
        Range("A" & st.Row, "E" & st.Row).Delete shift:=xlUp
        For x = 1 To lr
            Set st = .Cells.Find(what:="To Store:", after:=.Range("A" & r), LookIn:=xlValues, LookAt:= _
            xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
            , SearchFormat:=False)
            Set en = .Cells.Find(what:="Total to:", after:=.Range("A" & r), LookIn:=xlValues, LookAt:= _
            xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
            , SearchFormat:=False)
            .Range("B" & st.Row, "B" & en.Row).Value = .Range("B" & st.Row)
            r = en.Row
        Next
    End With
    End Sub
    Kind regards

  2. #2
    Forum Contributor
    Join Date
    12-17-2012
    Location
    indonesia
    MS-Off Ver
    Excel 2019
    Posts
    170

    Re: Macro to rename cell content based on the starting character until found same characte

    Dear Leo,

    Thx it worked.

+ 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. remove all text starting from specific character in a cell
    By itselflearn in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-24-2015, 12:17 PM
  2. How can i Found Space at end of character in a Cell?
    By Subashvivek in forum Hello..Introduce yourself
    Replies: 4
    Last Post: 08-08-2014, 12:59 AM
  3. Changing last character in a cell based on the character before it
    By Falcongbz in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 04-29-2013, 12:31 PM
  4. Macro to find character and delete all text in cell after the character
    By SpencerRichman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2012, 06:08 PM
  5. replace first character of cell content
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2009, 11:33 AM
  6. Clear content of cell if has some character.
    By Krzys in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-23-2007, 09:20 PM
  7. Truncate cell content after a certain character
    By brakai295 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2006, 07:33 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