excel column autofit

L

Lance Hoffmeyer

Hey all,

Wondering why the syntax won't autofit Column A?
I am not getting any errors.

Also, is there a way of reducing the number of
syntax lines? Basically, I am wondering if there
is an easier way to copy and paste?

Thanks in Advance.

Lance

# ADD ROW LABELS
sh = wb.Worksheets ("Total")
sh.Select()
sh.Range(sh.Cells(2,1), sh.Cells(20,1)).Select()
sh.Range(sh.Cells(2,1), sh.Cells(20,1)).Copy()
sh = wb.Worksheets ("Current Total")
sh.Select()
sh.Range(sh.Cells(2,1),sh.Cells(20,1)).Select()
sh.Paste()
sh.Columns("A:A").EntireColumn.AutoFit
 
J

Jeff Peck

Lance said:
Hey all,

Wondering why the syntax won't autofit Column A?
I am not getting any errors.

Also, is there a way of reducing the number of
syntax lines? Basically, I am wondering if there
is an easier way to copy and paste?

Thanks in Advance.

Lance

# ADD ROW LABELS
sh = wb.Worksheets ("Total")
sh.Select()
sh.Range(sh.Cells(2,1), sh.Cells(20,1)).Select()
sh.Range(sh.Cells(2,1), sh.Cells(20,1)).Copy()
sh = wb.Worksheets ("Current Total")
sh.Select()
sh.Range(sh.Cells(2,1),sh.Cells(20,1)).Select()
sh.Paste()
sh.Columns("A:A").EntireColumn.AutoFit
Looks like you just forgot to add the parenthesis after AutoFit

sh.Columns("A:A").EntireColumn.AutoFit()


Jeff
 
J

John Machin

Hey all,

Wondering why the syntax won't autofit Column A?
I am not getting any errors.

Also, is there a way of reducing the number of
syntax lines? Basically, I am wondering if there
is an easier way to copy and paste?

Thanks in Advance.

Lance

# ADD ROW LABELS
sh = wb.Worksheets ("Total")
sh.Select()
sh.Range(sh.Cells(2,1), sh.Cells(20,1)).Select()
sh.Range(sh.Cells(2,1), sh.Cells(20,1)).Copy()
sh = wb.Worksheets ("Current Total")
sh.Select()
sh.Range(sh.Cells(2,1),sh.Cells(20,1)).Select()
sh.Paste()
sh.Columns("A:A").EntireColumn.AutoFit

You need () after Autifit.
You need to look up "syntax" in a dictionary.

HTH,
John
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top