Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copy & Paste without the formulas

I have the following code which copies the a certain range
from several files (that only differs slightly by period
as handled by the variable r which runs through 1 to 7)
and pastes it into a workbook.

However, I only want to paste by value and format but it
is still holding the formulas from the other files
creating external links. Can someone please help to
explain why.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 07/30/2003 by Steven Cheng
'
Dim w As Workbook, cwkb As Workbook
Dim fname As String
Dim r As Integer, t As Integer

Set cwkb = ActiveWorkbook

For r = 1 To 7
fname
= "H:\ACCOUNT\AUDIT\SPREADS\DAILY\PAST_DLY\2003 Period " &
Format(r, "00") & ".xls"
Set w = Workbooks.Open(Filename:=fname)
w.Worksheets("Rooms").Range("B28:AD46").Copy
cwkb.Worksheets(1).Range("a1").Offset(19 * (r -
1), 0).PasteSpecial Paste:=xlValue
cwkb.Worksheets(1).Range("a1").Offset(19 * (r -
1), 0).PasteSpecial Paste:=xlFormats
w.Close savechanges:=False
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Copy & Paste without the formulas

I think it's a typo:

xlvalue should be xlvalues or xlpastevalues

From the immediate window:
?xlvalues
-4163
?xlpastevalues
-4163
?xlvalue
2


Yeah, it took awhile to notice it. I actually changed it to xlpastevalue and
that's when it blew up.

Steven Cheng wrote:

I have the following code which copies the a certain range
from several files (that only differs slightly by period
as handled by the variable r which runs through 1 to 7)
and pastes it into a workbook.

However, I only want to paste by value and format but it
is still holding the formulas from the other files
creating external links. Can someone please help to
explain why.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 07/30/2003 by Steven Cheng
'
Dim w As Workbook, cwkb As Workbook
Dim fname As String
Dim r As Integer, t As Integer

Set cwkb = ActiveWorkbook

For r = 1 To 7
fname
= "H:\ACCOUNT\AUDIT\SPREADS\DAILY\PAST_DLY\2003 Period " &
Format(r, "00") & ".xls"
Set w = Workbooks.Open(Filename:=fname)
w.Worksheets("Rooms").Range("B28:AD46").Copy
cwkb.Worksheets(1).Range("a1").Offset(19 * (r -
1), 0).PasteSpecial Paste:=xlValue
cwkb.Worksheets(1).Range("a1").Offset(19 * (r -
1), 0).PasteSpecial Paste:=xlFormats
w.Close savechanges:=False
End Sub


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copy & Paste without the formulas

Thanks Dave..how stupid of me.
-----Original Message-----
I think it's a typo:

xlvalue should be xlvalues or xlpastevalues

From the immediate window:
?xlvalues
-4163
?xlpastevalues
-4163
?xlvalue
2


Yeah, it took awhile to notice it. I actually changed it

to xlpastevalue and
that's when it blew up.

Steven Cheng wrote:

I have the following code which copies the a certain

range
from several files (that only differs slightly by period
as handled by the variable r which runs through 1 to 7)
and pastes it into a workbook.

However, I only want to paste by value and format but it
is still holding the formulas from the other files
creating external links. Can someone please help to
explain why.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 07/30/2003 by Steven Cheng
'
Dim w As Workbook, cwkb As Workbook
Dim fname As String
Dim r As Integer, t As Integer

Set cwkb = ActiveWorkbook

For r = 1 To 7
fname
= "H:\ACCOUNT\AUDIT\SPREADS\DAILY\PAST_DLY\2003

Period " &
Format(r, "00") & ".xls"
Set w = Workbooks.Open(Filename:=fname)
w.Worksheets("Rooms").Range("B28:AD46").Copy
cwkb.Worksheets(1).Range("a1").Offset(19 * (r -
1), 0).PasteSpecial Paste:=xlValue
cwkb.Worksheets(1).Range("a1").Offset(19 * (r -
1), 0).PasteSpecial Paste:=xlFormats
w.Close savechanges:=False
End Sub


--

Dave Peterson

.

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 and Paste formulas GG Excel Discussion (Misc queries) 1 October 30th 08 05:36 AM
Copy and paste a formulas ksyoung@novanthealth Excel Worksheet Functions 1 December 21st 06 02:22 PM
copy/paste vaules, not formulas jeremy via OfficeKB.com New Users to Excel 2 June 9th 05 12:02 AM
Copy/Paste formulas BobG Excel Discussion (Misc queries) 3 February 18th 05 05:11 PM
copy and paste formulas Jim Excel Worksheet Functions 4 January 14th 05 06:17 PM


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