format all column width

G

Guest

How can I write a macro so that it can format all column width equal to
standard
or exp=20
THe funtion if nice should apply for all sheets in a workbook?

Thanks
Daniel
 
G

Guest

Thanks Tom

If I have an existing sub, I just have to add below phase to my sub ?

for each sh in activeworkbook.Worksheets
sh.Columns.ColumnWidth = 8.43

Thanks
 
G

Guest

Most yes - but to be complete

for each sh in activeworkbook.Worksheets
sh.Columns.ColumnWidth = 8.43
next sh
 
G

Guest

Can I write sub in sub

sub ABC()


sub setcolumnwidht()
end sub
......
.......
end sub


Thanks
Daniel
 
G

Guest

Not much point in writing Sub in Sub, you can just write the lines of code to
do the job. However, if you want to only run a procedure under certain
conditions, or if you want to break a large procedure into several smaller
procedures, then you can call the sub routines from a main procedure by
simply using their name on a single line if they are in the same workbook:

Sub Main()
Range("A1").Activate
'Do Things
ABC 'Calls sub routine ABC and will return to next line after execution.
'Do more things
End Sub

See also "Call Statement" in VBA help file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top