View Single Post
  #4   Report Post  
TH6
 
Posts: n/a
Default Can someone tell me what is wrong with this code?

Try changing the order of the lines:

With Sheets("Sheet1")
Cells.Select
Selection.Columns.AutoFit
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End With

Works for me.

TH6

"Ant" wrote:

The debug occurs though on the line:

.Cells.Select

Also - it appears your solution is exactly the same as mine. Am I missing
something small perhaps?

Thanks in advance.

"TH6" wrote:

You have a bad line break:
use
.Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
or
.Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks _



"Ant" wrote:

With Sheets("Sheet1")
.Cells.EntireColumn.AutoFit
.Cells.Select
.Selection.Copy
.Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End With