hi all,
how can I programatically adjust width of column (on excel sheet) to the "width" of data that I am pasting into a row. to insert data I am using ado.
thx in advance for your help
regards,
sweet_dreams
Printable View
hi all,
how can I programatically adjust width of column (on excel sheet) to the "width" of data that I am pasting into a row. to insert data I am using ado.
thx in advance for your help
regards,
sweet_dreams
If you are using ADO, you cannot control formatting in any manner whatsoever. You will need to use Automation to be able to set formatting.
Use the following code snippet to auto adjust the width of column "A".
VB Code:
Worksheets("Sheet1").Range("A1").Columns.AutoFit
Hi DKenny,
Unfortunatelly when I write the code that you advised me I get such an error:
What should I do then???Quote:
Run-time error 9
Subscript out of range
Please help,
Regards
sweet_dreams
Why paste it in when you are using ADO if you add the use of the Excel Object Model?. Like DKenny posted but change "Sheet1" to whatever your sheets name is. This is why your getting the subscript out of range error - 9.
RobDog888,
the problem is that I've changed the sheet name
Changed via during your ode execution or manually? Just change "Sheet1" to whatever your new sheet name is now.
RobDog888,
As I have stated I changed sheet name for the name that exists in my workbook, to which sheet I want this code refer to.
So it works for you now?
no, after changing the name I get the same error message
Did you save the workbook and maybe close and reopen Excel.