Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Copy Cells with More than 255 Characters

If a sheet is copied with cells having a length of more than 255
characters then a truncation error occurs on those cells.

Excel prompts to use a copying of cells rahter than whole sheets. This
is fine if the cells in the original sheet have not been merged.
Unfortunately, my sheet includes extensive use of long text strings in
merged cells.

Has anyone a workaround for this, please?

Any help would be a greatly appreciated

Tim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copy Cells with More than 255 Characters

Tim

Here is some code which seems to work for me. I would switch excel
into manual calculation before running the code.

Peter

Sub CopySelectedSheets()
Dim NoSh As Integer, SheetNames() As String, PNoSh As Integer, Nc As Integer
Dim SrcB As Workbook, DesB As Workbook

With ActiveWindow.SelectedSheets
ReDim SheetNames(1 To .Count)
For Nc = 1 To .Count
SheetNames(Nc) = .Item(Nc).Name
Next
End With

NoSh = Nc - 1
PNoSh = Application.SheetsInNewWorkbook

Application.SheetsInNewWorkbook = NoSh
Set SrcB = ActiveWorkbook
Set DesB = Workbooks.Add
For Nc = 1 To NoSh
SrcB.Sheets(SheetNames(Nc)).Cells.Copy _
Destination:=DesB.Sheets(Nc).Cells
DesB.Sheets(Nc).Name = SheetNames(Nc)
Next

Application.SheetsInNewWorkbook = PNoSh

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copy Cells with More than 255 Characters

Tim

Here is some code which seems to work for me. I would switch excel
into manual calculation before running the code.

Sub CopySelectedSheets()
Dim NoSh As Integer, SheetNames() As String, PNoSh As Integer, Nc
As Integer
Dim SrcB As Workbook, DesB As Workbook

With ActiveWindow.SelectedSheets
ReDim SheetNames(1 To .Count)
For Nc = 1 To .Count
SheetNames(Nc) = .Item(Nc).Name
Next
End With

NoSh = Nc - 1
PNoSh = Application.SheetsInNewWorkbook

Application.SheetsInNewWorkbook = NoSh
Set SrcB = ActiveWorkbook
Set DesB = Workbooks.Add
For Nc = 1 To NoSh
SrcB.Sheets(SheetNames(Nc)).Cells.Copy _
Destination:=DesB.Sheets(Nc).Cells
DesB.Sheets(Nc).Name = SheetNames(Nc)
Next

Application.SheetsInNewWorkbook = PNoSh

End Sub
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Copy Cells with More than 255 Characters

Peter

Many thanks for coming back on this.

The one thing that is then missing from the copy is the properties of
the sheet itself e.g the print pagesetup.

Best wishes

Tim
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
Copy all but last 9 characters of a cell Ben Excel Discussion (Misc queries) 6 April 17th 23 06:58 PM
Copy string of characters BRB Excel Discussion (Misc queries) 4 August 27th 08 12:28 PM
How do I copy more than 255 characters per cell? JR Excel Discussion (Misc queries) 2 June 20th 07 08:40 PM
copy select characters from specified cells. Ron Excel Worksheet Functions 3 October 9th 06 08:40 PM
Copy data where some cells exceed 256 characters Stuart[_5_] Excel Programming 2 November 19th 03 05:49 PM


All times are GMT +1. The time now is 11:17 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"