Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Paste Special


Hi all, I have some code below that another user kindly provided bu
would ask if anybody could help me with a slight modification - th
code will copy and paste special a range from one worksheet to anothe
worksheet and works great - but I have had some items that start wit
zero's in the origin and after the paste special ( because I only wan
values and not formula's to copy ) will convert say '012345 to 1234
but I do need the '012345 to be displayed as it is - any suggestion
will be kindly received.

Dim sourceRange As Range
Dim destrange As Range
Dim Lr As Long
Lr = LastRow(Sheets("Worksheet1")) + 1
Set sourceRange = Sheets("Worksheet2").Range("BO7:CZ21")
With sourceRange
Set destrange = Sheets("Worksheet1").Range("A" & Lr). _
Resize(.Rows.Count, .Columns.Count)
End With
destrange.Value = sourceRange.Value
End Sub

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function

Function Lastcol(sh As Worksheet)
On Error Resume Next
Lastcol = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End Functio

--
spar
-----------------------------------------------------------------------
sparx's Profile: http://www.excelforum.com/member.php...fo&userid=1678
View this thread: http://www.excelforum.com/showthread.php?threadid=55165

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Paste Special

Add this line...
destrange.NumberFormat = "@"
just before this line...
destrange.Value = sourceRange.Value
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"sparx"

wrote in message
Hi all, I have some code below that another user kindly provided but
would ask if anybody could help me with a slight modification - the
code will copy and paste special a range from one worksheet to another
worksheet and works great - but I have had some items that start with
zero's in the origin and after the paste special ( because I only want
values and not formula's to copy ) will convert say '012345 to 12345
but I do need the '012345 to be displayed as it is - any suggestions
will be kindly received.

Dim sourceRange As Range
Dim destrange As Range
Dim Lr As Long
Lr = LastRow(Sheets("Worksheet1")) + 1
Set sourceRange = Sheets("Worksheet2").Range("BO7:CZ21")
With sourceRange
Set destrange = Sheets("Worksheet1").Range("A" & Lr). _
Resize(.Rows.Count, .Columns.Count)
End With
destrange.Value = sourceRange.Value
End Sub

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function

Function Lastcol(sh As Worksheet)
On Error Resume Next
Lastcol = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End Function
  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Paste Special

Instead of

destrange.Value = sourceRange.Value

try

sourceRange.Copy destrange

Does that help?

"sparx" wrote:


Hi all, I have some code below that another user kindly provided but
would ask if anybody could help me with a slight modification - the
code will copy and paste special a range from one worksheet to another
worksheet and works great - but I have had some items that start with
zero's in the origin and after the paste special ( because I only want
values and not formula's to copy ) will convert say '012345 to 12345
but I do need the '012345 to be displayed as it is - any suggestions
will be kindly received.

Dim sourceRange As Range
Dim destrange As Range
Dim Lr As Long
Lr = LastRow(Sheets("Worksheet1")) + 1
Set sourceRange = Sheets("Worksheet2").Range("BO7:CZ21")
With sourceRange
Set destrange = Sheets("Worksheet1").Range("A" & Lr). _
Resize(.Rows.Count, .Columns.Count)
End With
destrange.Value = sourceRange.Value
End Sub

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function

Function Lastcol(sh As Worksheet)
On Error Resume Next
Lastcol = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
On Error GoTo 0
End Function


--
sparx
------------------------------------------------------------------------
sparx's Profile: http://www.excelforum.com/member.php...o&userid=16787
View this thread: http://www.excelforum.com/showthread...hreadid=551652


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Paste Special


I will try both methods you describe.


--
sparx
------------------------------------------------------------------------
sparx's Profile: http://www.excelforum.com/member.php...o&userid=16787
View this thread: http://www.excelforum.com/showthread...hreadid=551652

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
Paste and Paste Special No Longer Working - Excel 2003 SheriJ Excel Discussion (Misc queries) 2 January 15th 09 09:23 PM
'paste special', 'paste link' formatting transfer jrebello Excel Discussion (Misc queries) 2 July 25th 07 08:46 AM
In Excel: add a Paste-Special Option to paste IN REVERSE ORDER. stan-the-man Excel Worksheet Functions 7 June 14th 06 08:10 PM
How do I capture user paste action and convert to Paste Special DonC Excel Programming 0 November 19th 04 01:43 PM
Dynamic Copy/Paste Special Formulas/Paste Special Values Sharon Perez Excel Programming 3 August 7th 04 09:49 PM


All times are GMT +1. The time now is 05:18 PM.

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"