Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
HJ HJ is offline
external usenet poster
 
Posts: 28
Default Paste values & formats

Can anyone tell me how/where I would add code to this macro to paste both
values and formats? TIA

Sub CopyClosingData()
Dim i As Long, rng As Range, sh As Worksheet
Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = "ClosingData"
Set sh = Worksheets("Closings")
i = 12
Do While Not IsEmpty(sh.Cells(i, 1))
Set rng = Union(sh.Cells(i, 1), _
sh.Cells(i + 1, 1).Resize(2, 1))
rng.EntireRow.Copy Destination:= _
Worksheets("ClosingData").Cells(Rows.Count, 1).End(xlUp)(2)
i = i + 12
Loop
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Paste values & formats

Sub CopyClosingData()
Dim i As Long, rng As Range, sh As Worksheet
Dim rng1 as Range
Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = "ClosingData"
Set sh = Worksheets("Closings")
i = 12
Do While Not IsEmpty(sh.Cells(i, 1))
Set rng = Union(sh.Cells(i, 1), _
sh.Cells(i + 1, 1).Resize(2, 1))
rng.EntireRow.Copy
set rng1 = Worksheets("ClosingData") _
.Cells(Rows.Count, 1).End(xlUp)(2)
rng1.PasteSpecial xlValues
rng1.PasteSpecial xlFormats
i = i + 12
Loop
End Sub

--
Regards,
Tom Ogilvy

"HJ" wrote in message
...
Can anyone tell me how/where I would add code to this macro to paste both
values and formats? TIA

Sub CopyClosingData()
Dim i As Long, rng As Range, sh As Worksheet
Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = "ClosingData"
Set sh = Worksheets("Closings")
i = 12
Do While Not IsEmpty(sh.Cells(i, 1))
Set rng = Union(sh.Cells(i, 1), _
sh.Cells(i + 1, 1).Resize(2, 1))
rng.EntireRow.Copy Destination:= _
Worksheets("ClosingData").Cells(Rows.Count, 1).End(xlUp)(2)
i = i + 12
Loop
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Paste values & formats

hi,
try this
rng.EntireRow.Copy
Worksheets("ClosingData").Cells(Rows.Count, 1).End(xlUp)(2)

-----Original Message-----
Can anyone tell me how/where I would add code to this

macro to paste both
values and formats? TIA

Sub CopyClosingData()
Dim i As Long, rng As Range, sh As Worksheet
Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = "ClosingData"
Set sh = Worksheets("Closings")
i = 12
Do While Not IsEmpty(sh.Cells(i, 1))
Set rng = Union(sh.Cells(i, 1), _
sh.Cells(i + 1, 1).Resize(2, 1))
rng.EntireRow.Copy Destination:= _
Worksheets("ClosingData").Cells(Rows.Count, 1).End

(xlUp)(2)
i = i + 12
Loop
End Sub
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Paste values & formats

hi again,
oops Sorry.
I ment try this
change the copy command
rng.EntireRow.Copy
Worksheets("ClosingData").Cells(Rows.Count, 1).End
(xlUp).select
Selection.PasteSpecial xlpasteall

sheets("closings").select
Rng.select
untested but i have used this before.

-----Original Message-----
Can anyone tell me how/where I would add code to this

macro to paste both
values and formats? TIA

Sub CopyClosingData()
Dim i As Long, rng As Range, sh As Worksheet
Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = "ClosingData"
Set sh = Worksheets("Closings")
i = 12
Do While Not IsEmpty(sh.Cells(i, 1))
Set rng = Union(sh.Cells(i, 1), _
sh.Cells(i + 1, 1).Resize(2, 1))
rng.EntireRow.Copy Destination:= _
Worksheets("ClosingData").Cells(Rows.Count, 1).End

(xlUp)(2)
i = i + 12
Loop
End Sub
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
HJ HJ is offline
external usenet poster
 
Posts: 28
Default Paste values & formats

Tom,

Thanks so much!! Once again, you've saved me a lot of time!!

"Tom Ogilvy" wrote:

Sub CopyClosingData()
Dim i As Long, rng As Range, sh As Worksheet
Dim rng1 as Range
Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = "ClosingData"
Set sh = Worksheets("Closings")
i = 12
Do While Not IsEmpty(sh.Cells(i, 1))
Set rng = Union(sh.Cells(i, 1), _
sh.Cells(i + 1, 1).Resize(2, 1))
rng.EntireRow.Copy
set rng1 = Worksheets("ClosingData") _
.Cells(Rows.Count, 1).End(xlUp)(2)
rng1.PasteSpecial xlValues
rng1.PasteSpecial xlFormats
i = i + 12
Loop
End Sub

--
Regards,
Tom Ogilvy

"HJ" wrote in message
...
Can anyone tell me how/where I would add code to this macro to paste both
values and formats? TIA

Sub CopyClosingData()
Dim i As Long, rng As Range, sh As Worksheet
Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = "ClosingData"
Set sh = Worksheets("Closings")
i = 12
Do While Not IsEmpty(sh.Cells(i, 1))
Set rng = Union(sh.Cells(i, 1), _
sh.Cells(i + 1, 1).Resize(2, 1))
rng.EntireRow.Copy Destination:= _
Worksheets("ClosingData").Cells(Rows.Count, 1).End(xlUp)(2)
i = i + 12
Loop
End Sub






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Paste values & formats

Why?

xlPasteAll just takes two commands to do what the code is already doing in
one and doesn't do what the OP asked.

--
Regards,
Tom Ogilvy

wrote in message
...
hi again,
oops Sorry.
I ment try this
change the copy command
rng.EntireRow.Copy
Worksheets("ClosingData").Cells(Rows.Count, 1).End
(xlUp).select
Selection.PasteSpecial xlpasteall

sheets("closings").select
Rng.select
untested but i have used this before.

-----Original Message-----
Can anyone tell me how/where I would add code to this

macro to paste both
values and formats? TIA

Sub CopyClosingData()
Dim i As Long, rng As Range, sh As Worksheet
Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = "ClosingData"
Set sh = Worksheets("Closings")
i = 12
Do While Not IsEmpty(sh.Cells(i, 1))
Set rng = Union(sh.Cells(i, 1), _
sh.Cells(i + 1, 1).Resize(2, 1))
rng.EntireRow.Copy Destination:= _
Worksheets("ClosingData").Cells(Rows.Count, 1).End

(xlUp)(2)
i = i + 12
Loop
End Sub
.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Paste values & formats

Tom..

I suggest reversing the pasting sequence has a few advantages
and may give fewer problems with text/dates and merged cells.

rng1.PasteSpecial xlFormats
rng1.PasteSpecial xlValues



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Tom Ogilvy" wrote :

Sub CopyClosingData()
Dim i As Long, rng As Range, sh As Worksheet
Dim rng1 as Range
Worksheets.Add(After:=Worksheets( _
Worksheets.Count)).Name = "ClosingData"
Set sh = Worksheets("Closings")
i = 12
Do While Not IsEmpty(sh.Cells(i, 1))
Set rng = Union(sh.Cells(i, 1), _
sh.Cells(i + 1, 1).Resize(2, 1))
rng.EntireRow.Copy
set rng1 = Worksheets("ClosingData") _
.Cells(Rows.Count, 1).End(xlUp)(2)
rng1.PasteSpecial xlValues
rng1.PasteSpecial xlFormats
i = i + 12
Loop
End Sub


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
Keyboard Shortcuts for Paste Special Values and Formats Scott Excel Discussion (Misc queries) 3 May 20th 23 11:41 AM
copy & paste values+formats from excel to word rockhammer Excel Discussion (Misc queries) 2 May 17th 09 02:29 AM
Paste Values and Formats Only???? [email protected] Excel Discussion (Misc queries) 2 September 2nd 08 09:00 PM
Conditional formats- paste special formats? jcarney Excel Discussion (Misc queries) 1 November 1st 07 06:37 PM
paste conditional formats as formats leo Excel Discussion (Misc queries) 2 July 5th 07 10:06 AM


All times are GMT +1. The time now is 03:44 PM.

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

About Us

"It's about Microsoft Excel"