Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default Paste Special won't work in VBA

Once again, I have run into something I don't understand. I copy an entire
spreadsheet, go to a blank sheet, and Paste Special for values, column
widths, and formats. I used the macro recorder to get the syntax for the
Paste Special events.



The Column Widths, though, won't work in VBA. Values and Formats do, but
Formats won't do the Column Widths in VBA. On a right click, though, I can
do both Formats - which will include Column Widths - and just Column Widths.



The beginning of the code which includes the Paste Specials follows. Any
help is appreciated.



Ed



Sub SlimFile()

'

' SlimFile Macro

' Macro recorded 8/15/2003 by Authorized User



' Turn off alerts

Application.DisplayAlerts = False



' Add new worksheet

Sheets.Add



' Copy info from Sheet1

Sheets("Sheet1").Select

Cells.Select

Selection.Copy



' Paste values, formats to Sheet 2

Sheets("Sheet2").Select

Range("A1").Select

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_

False, Transpose:=False

Range("A1").Select

Selection.PasteSpecial Paste:=xlColumnWidths, Operation:=xlNone, _

SkipBlanks:=False, Transpose:=False

Range("A1").Select

Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:=
_

False, Transpose:=False

Range("A1").Select


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Paste Special won't work in VBA

There was a problem with xlColumnWidths in Excel 2000. Instead try this:

PasteSpecial Paste:=8


--
Jim Rech
Excel MVP


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Paste Special won't work in VBA

True, but to add a thought:

Cells.Copy

then
Range("A1").PasteSpecial xlFormats

should paste column widths and row heights as well since entire columns/rows
are being pasted.

so pasting column widths should be redundant.

--
Regards,
Tom Ogilvy


"Jim Rech" wrote in message
...
There was a problem with xlColumnWidths in Excel 2000. Instead try this:

PasteSpecial Paste:=8


--
Jim Rech
Excel MVP




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default Paste Special won't work in VBA

I tried that, Tom, especially since it worked that way from a right
clickPaste SpecialFormats. But in VBA, even as recorded, I got formats
but not the column widths. That's why I put it in separately. Then I kept
getting "Paste Special method of range class failed" errors.

The Paste:=8 worked for widths. But I had pasted Values first, and it
overwrote my values! Okay, so I change things around and do the values
last. *sigh*

Ed


"Tom Ogilvy" wrote in message
...
True, but to add a thought:

Cells.Copy

then
Range("A1").PasteSpecial xlFormats

should paste column widths and row heights as well since entire

columns/rows
are being pasted.

so pasting column widths should be redundant.

--
Regards,
Tom Ogilvy


"Jim Rech" wrote in message
...
There was a problem with xlColumnWidths in Excel 2000. Instead try

this:

PasteSpecial Paste:=8


--
Jim Rech
Excel MVP






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
why don't my functions in paste special work? Gene Excel Worksheet Functions 2 September 10th 06 05:33 PM
Paste special from MS Project to Excel does not always work?? JCBang Excel Discussion (Misc queries) 0 July 21st 06 02:27 PM
Paste special into a filtered work sheet SmithDelgado Excel Worksheet Functions 0 June 20th 06 06:20 PM
How does the PASTE.SPECIAL function work? Curt Excel Discussion (Misc queries) 6 July 28th 05 07:58 PM
paste special | values should work with merged cells PastingSpecial Excel Discussion (Misc queries) 1 June 20th 05 06:51 PM


All times are GMT +1. The time now is 08:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"