Free Support Forum -

Apply bold fonts (or other formattings) to a range of cells


I am a bit confused after going over the documentation part. I read somewhere the Style is obsolete and to instead use the ApplyStyle method. So I'd like your help.

I am using v5.3.3 with .NET 4. I am passing a range of cells (say A4:N4) as parameter to a procedure where we will set Font = true (so all the cells in that range have that particular style). This is what i was doing so far -

Protected Friend Sub BoldFont(ByVal range As String)

Dim s As Style

s = objcells(range).GetStyle

s.Font.IsBold = True


s = Nothing

End Sub

Is this correct? If so, when I pass a single cell as Xcel.BoldFont("A9") it works. But when I pass a range of cells as Xcel.BoldFont("A9:N9") it says I'm passing an invalid cell name. How should i correct this?

On a related question, how can i apply a custom number format (something that I'd like to pass to the function) to a cell or a range of cells?

Also, can I do the same for other styles/formattings to achieve the same result? And what's the best way to search through your documentation for a particular topic? All i can do is type what i'm searching in the Search box and it returns results from everywhere (forum, documentation, etc). Is there an easier way to drill down the documentation?




Please see the the document:

Check especially the sub-topic “Format Ranges…Setting Background Color and Font Attributes to a Named Range”. Please note that you will use Range.ApplyStyle(styleObject, styleFlagObject), so using this technique, you may apply all types of formatting (back/fore color, font attributes, number formattings etc.).

Thank you.

And, for obtaining specific search results, please click on "More Search Options" link and set your desired criteria to get your desired results:

Thank you.