Formatting a cell in an Excel Macro - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Formatting a cell in an Excel Macro

the_Rthe_R Posts: 2Member
Hi guys,

just wondering if you can help me with a macro im doing.

I need it to preserve the format of one cell and copy it into another.

For example, if half of the text is in bold, it needs to stay bold when copying it.

i dont know how to change the boldness without changing it for the entire cell.

Thanks

Comments

  • FazFaz Posts: 75Member
    : Hi guys,
    :
    : just wondering if you can help me with a macro im doing.
    :
    : I need it to preserve the format of one cell and copy it into another.
    :
    : For example, if half of the text is in bold, it needs to stay bold when copying it.
    :
    : i dont know how to change the boldness without changing it for the entire cell.
    :
    : Thanks
    :
    I just tried copying a cell that had text in it with half of it bold and it copies fine. If it is just the formatting you're after to copy and not the text then yes the formatting seems to just fill itself across the entire cell. Do you want the first half to be bold, or the first x characters to be bold? One easy way out is to split the string into 2 columns but have the left column with text alligned right and the right hand column with text alligned left, then you have 2 seperate cells, which look like they haven't been split at all. And if you need to, there's an easy concatenate function I'm sure you might already know that combines the contents of cells and strings.

    Another much more trickier way to make the first 5 characters of a cell bold is to create a macro that will cycle through each of the cells you want to apply this 'special' format on and get it to select the first 5 characters and set them to bold. I have done this before but I had no idea what the code looked like! So it was recorded! Just type in a string of about 10 characters into a cell. Then start recording a macro and highlight the first 5 characters and set them to bold, the recorder does pick up on this. Then just edit the code as you would.
Sign In or Register to comment.