
19-05-12, 18:10
|
| Όνομα: Θανάσης Έκδοση λογισμικού Office: Ms-Office 2013 Γλώσσα λογισμικού Office: Αγγλική | | Εγγραφή: 13-02-2010
Μηνύματα: 62
| |
Θανάση,
Βρήκα ένα ενδιαφέρον άρθρο στο internet (Humar December 29, 2009 at 06:55:53 Pacific)
που με κάποιες αλλαγές θα μπορούσα να το χρησιμοποιήσω.
Δυστυχώς για μένα δεν ξέρω πως να τις κάνω χρησιμοποιώντας ένα module.
Εάν κάποιος μπορεί να βοηθήσει θα του ήμουν ευγνώμων. Κώδικας:
Here is a way to bold a list of words inside a longer phrase.
It requires visual basic and it uses the Change event.
For this example three words will be included in the new phrase and will be Bolded.
Put three words in cells E4, E5 and E6:
E
4 Wayne
5 John
6 big
Put this formula in cell E8:
="Films with "&E6&" film actor "&E5&" "&E4
Now right click on the Sheet name tab at the bottom of the Excel window. This example used Sheet1.
Select View Code
In the window that opens enter this code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim objISect As Range
'this range object is created if the changed range (Target)
'contains any part of range E4:E6
Set objISect = Intersect(Target, Range("E4:E6"))
'make the changes if the range object has been set (i.e. is Not Nothing)
If Not objISect Is Nothing Then
'create the new string in cell E9
Range("E9").Value = Range("E8").Text
'remove any existing Bold font
Range("E9").Font.Bold = False
'now bold each of the words from the list E4:E6
Range("E9").Characters(InStr(1, Range("E9").Text, Range("E4").Text), _
Len(Range("E4").Text)).Font.Bold = True
Range("E9").Characters(InStr(1, Range("E9").Text, Range("E5").Text), _
Len(Range("E5").Text)).Font.Bold = True
Range("E9").Characters(InStr(1, Range("E9").Text, Range("E6").Text), _
Len(Range("E6").Text)).Font.Bold = True
End If
End Sub
To use more words, change the range in the line starting Set objIsect
For a fourth word the line becomes:Set objISect = Intersect(Target, Range("E4:E7"))
and add a new line under the heading 'now bold each of the words from the list E4:E6
Note that there are three lines of code, but each has been split onto two visual lines using the '_' character.
Just copy the last two visual lines, and paste them before End if, and change the E6 to E7 for a fourth word.
When you change any word in your list a new phrase with bolded text appears in cell E9.
Note that when you move cells referenced in this code, the code does not change, so you will have to change
the code to show the new cell addresses.
Regards
Ευχαριστώ εκ των προτέρων.
|