Set Multiple Column Widths

  • Hi All,


    I've used the macro recorder to try to auto-apply column widths after I do a CSV import:
    (A&B=3.14, C=8, D=13.57, E=24.14, F=9, G=10, H=11.29, I=8.57, J=6.86, K=8, L=13, M=10)


    ...but for some reason when I execute this macro, "every" column gets the width of 10!


    May I pls ask what I'm doing wrong, or how I can fix the below code?



    Thanks in advance,
    CG

  • Re: Column Width Macro


    Dunno. You don't need the Selects. This worked fine for me.

    [SIZE=1]Entia non sunt multiplicanda sine necessitate.[/SIZE]

  • Re: Column Width Macro


    Thanks shg! You're awesome! This worked perfectly! ...and even better, it's more efficient. I like the fact that cells don't need to be highlighted beforehand, and even don't flicker anymore on execution. Thanks again for the very fast reply!


    CG

  • Re: Column Width Macro


    Quote from shg

    You're welcome. Why not just do

    Code
    Columns.Autofit


    Mainly because I wanted to allow the columns to fit on a printed-out page horizontally. If any text is too large, I have the columns set to wrap to the next line in the cell.


    Thinking of how you showed that I didn't need to highlight the columns going across, I'm also probably doing the cell wrapping inefficiently as well (wanted to wrap the text in the cells from Row #4 down to the rest of the spreadsheet. I currently have:


    ...but have a feeling that I can do something similar to what you've shown me above (thank you again, btw!), so that I wouldn't need to highlight those rows in order to wrap text within those rows.


    CG

  • Re: Column Width Macro


    If those are part of style Normal, then just do

    Code
    Cells.Style = "Normal"


    Or create a style with those attributes ...

    [SIZE=1]Entia non sunt multiplicanda sine necessitate.[/SIZE]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!