+ Reply to Thread
Results 1 to 4 of 4

VBA help needed to find text string, clear cells then add new cell value

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Question VBA help needed to find text string, clear cells then add new cell value

    Folks,

    Please help me to build a Macro to search text string "WorkPack Approval:" in Column A, then clear all contents from cell contains text string "WorkPack Approval:" to just above text string "Comments:". And add new cell value in the same cell as "LOG BOOK:"

    I have attached the work book of what I am trying to accomplish.


    Thanks in advance for your time and expertise
    Attached Files Attached Files
    Cheers,

    Joshi
    Being with a winner makes you a winner

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: VBA help needed to find text string, clear cells then add new cell value

    Try this, but those merged cells are horrible:
    Sub x()
      
    Dim rFind1 As Range, rFind2 As Range
     
    With Sheet1.UsedRange
        Set rFind1 = .Find(What:="Workpack Approval:", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
        If Not rFind1 Is Nothing Then
            Do
                Set rFind2 = .Find(What:="Comments:", After:=rFind1, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
                If Not rFind2 Is Nothing Then
                    With Range(rFind1, rFind2.Offset(-1)).Resize(, 6)
                        .ClearContents
                        .Interior.Color = vbYellow
                        .Merge
                        .Value = "LOG BOOK"
                        .Font.Size = 48
                        .HorizontalAlignment = xlCenter
                    End With
                    Set rFind1 = .Find(What:="Workpack Approval:", After:=rFind2, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
                End If
            Loop While Not rFind1 Is Nothing
        End If
    End With
         
    End Sub
    Last edited by StephenR; 03-13-2014 at 08:17 AM.

  3. #3
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA help needed to find text string, clear cells then add new cell value

    Sub macro_1()
    Dim wpa_row, com_row
    wpa_row = WorksheetFunction.Match("WorkPack Approval:", Columns(1), 0)
    com_row = WorksheetFunction.Match("Comments:", Columns(1), 0)
    With Range("A" & wpa_row & ":F" & com_row - 1)
        .ClearContents
        .Merge
        .Value = "LOG BOOK"
        .Font.Size = 48
        .HorizontalAlignment = xlCenter
        .Font.Color = vbRed
    End With
    End Sub
    ?

  4. #4
    Forum Contributor
    Join Date
    10-30-2011
    Location
    Doha
    MS-Off Ver
    MS office 365
    Posts
    701

    Re: VBA help needed to find text string, clear cells then add new cell value

    Hi Stephen & ragulduy,

    Thanks you so much gents. Your code is working excellent.


    Joshi

+ 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. if column equals text string clear cells
    By wacky_diva in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-18-2013, 08:59 PM
  2. [SOLVED] Find partial text string within another text string return original text into cell.
    By mikey42979 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-17-2013, 02:58 PM
  3. [SOLVED] VBA Needed to find number/text within cell string and copy out to new cell
    By Campbell A in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-19-2013, 10:15 AM
  4. Find Text String in Range of Cells
    By super21 in forum Excel General
    Replies: 2
    Last Post: 08-03-2012, 01:56 AM
  5. Macro to find bold cells then clear adjacent cell
    By painterartist in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-26-2011, 04:47 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