0

I have two cells (let"s say A1 and B1) with same content, but not same formatting (borders, size, background, etc.)

I need to have the same bold words in the two cells. But I don't want to change any other formattings of A1 and B1

I've made a loop on the text in A1 in order to detect if each letter is in bold or not:

For i = 1 To Len([A1])

If [A1].Characters(i, 1).Font.Bold = True Then [B1].Characters(i, 1).Font.Bold = True

Next i

When the length of the text in A1 exceeds 200 letters, this loop takes several seconds to execute, and I need to optimize it.

My idea is to transfer the "[A1].characters" object in a variable, in order to check faster whether each letter of A1 is in bold or not.

So I create the object [A1].characters:

set chr=[A1].characters

How can I get the property "bold/not bold" of each letter of the text?

(I'vee been looking for a way to build an array which dimension is the number of letters of A1, with 1's for bold letters and 0's for not bold letters, but I can't find it)

Thanks in advance for your help.

3
  • A faster way would be to get the format of cell B1 you want to keep, copy cell A1 into B1, then apply the original formatting back on B1. Jan 16, 2019 at 17:35
  • Would it really be faster? keeping copy of all formattings, implies keeping copy of all borders formatting, background formatting, poloce formatting, alignment formatting, etc (Big macro!)
    – pruvieros
    Jan 17, 2019 at 5:46
  • Please edit your question to give us an example of what you have and what the expected result is. This may be useful to help creating a good example. Jan 17, 2019 at 12:45

0

You must log in to answer this question.

Browse other questions tagged .