#1
|
|||
|
|||
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. |
#2
|
|||
|
|||
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? |
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
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 Charles |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Excel VBA Macro - Deleting Specific Data based on criteria | MD011 | Excel Programming | 3 | 12-10-2014 02:15 AM |
Macro for word to add page break and specific text to end of document | pizzaman1 | Word VBA | 6 | 11-14-2014 11:25 PM |
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 |
Macro to copy specific columns in Excel from another spreadsheet | KD999 | Excel Programming | 1 | 07-20-2012 08:58 AM |