Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-15-2015, 01:16 AM
ducky831 ducky831 is offline Excel Macro finding a specific word Windows 10 Excel Macro finding a specific word Office 2013
Novice
Excel Macro finding a specific word
 
Join Date: Sep 2015
Posts: 1
ducky831 is on a distinguished road
Default Excel Macro finding a specific word


o I am trying to make a macro to find a specific string of words (Total Revenue and Other Income) in a Income Statement and once it does, it will select those words and bold it. After it does that, any box to the right that contains values will be selected to have "top and thick bottom border" and bold as well

so for example



the macro would find the string and then does this



Please help me, I have more than 100 files that has over 500 lines and I need to do something like this in all of them.
Reply With Quote
  #2  
Old 09-16-2015, 12:33 PM
charlesdh charlesdh is offline Excel Macro finding a specific word Windows 7 32bit Excel Macro finding a specific word Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

Hi,

Welcome to the forum.
Can you attach a file so we see what you are working with.
The files you mentioned are they in the same workbook?
Reply With Quote
  #3  
Old 09-16-2015, 04:18 PM
charlesdh charlesdh is offline Excel Macro finding a specific word Windows 7 32bit Excel Macro finding a specific word Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

Hi,

Thought I'd let you know I have some code worked out, but would like to see what the format for your file is . Also as mentioned before is all of the file in the same workbook.
So, if you will attach a sample of you file. If I do not get back to you tomorrow.
Else, another member may help.

Charles
Reply With Quote
  #4  
Old 09-17-2015, 01:36 PM
charlesdh charlesdh is offline Excel Macro finding a specific word Windows 7 32bit Excel Macro finding a specific word Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

Ni,

Not knowing how you have your file set this code will be limited.
It will find the text you specified and bold it. It will then go to the next column in the same row as the specified text and if there is data it will underline the cell "Bold" it will do this for 4 columns only.
Paste the code to a module and test it.
Test on copy data only.

Code:
Sub Find_Specific_String()
Dim varFound As Variant, varSearch As Variant
Dim strAddress As String, intPos As Integer
Dim i As Long
varSearch = "Total Revenue and Other Income"
Set varFound = Cells.Find(varSearch, LookIn:=xlValues, LookAt:=xlPart)

If Not varFound Is Nothing Then
    With varFound
    intPos = InStr(intPos + 1, .Value, varSearch, vbTextCompare)
        If intPos Then
            .Characters(Start:=intPos, Length:=Len(varSearch)).Font.FontStyle = "Bold"
            For i = 1 To 4 '' this will only loop  4 columns
                If Cells(varFound.Row, 2).Text <> "" Then
                With Cells(varFound.Row, 2).Borders(xlEdgeBottom)
                    .LineStyle = xlContinuous
                    .Weight = xlMedium
                    .ColorIndex = 1
                End With
                End If
            Next i
        End If
    End With
End If
End Sub
You need to provide a file that we can work with in order to make corrections to the code supplied.

Charles
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Macro finding a specific word Excel VBA Macro - Deleting Specific Data based on criteria MD011 Excel Programming 3 12-10-2014 02:15 AM
Excel Macro finding a specific word Macro for word to add page break and specific text to end of document pizzaman1 Word VBA 6 11-14-2014 11:25 PM
Excel Macro finding a specific word Macro to insert multiple pictures to word to a specific size and text wrap mescaL Word VBA 3 11-03-2014 10:51 PM
Finding specific text within body of email Tammfran Outlook 0 03-14-2014 02:32 PM
Excel Macro finding a specific word Macro to copy specific columns in Excel from another spreadsheet KD999 Excel Programming 1 07-20-2012 08:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft