Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default copy\paste with vba

I created a macro to copy and paste the formulas from one row to
another. I dont want to copy the the values.
When I run it, it copys the formulas but ALSO the values. What am i
doing wrong? Can someone help me?

-------------------------------------------------------------------------
Application.Goto Reference:="totaal"
Selection.EntireRow.Insert
Application.Goto Reference:="totaal"
ActiveCell.Offset(-2, -35).Range("A1:AJ1").Select

Selection.Copy
Application.Goto Reference:="totaal"
ActiveCell.Offset(-1, -35).Range("A1:AJ1").Select

Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub

--------------------------------------------------------------------------


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default copy\paste with vba

From XL/VBA Help (Formula Property)

If the cell contains a constant, this property returns the constant. If the
cell is empty, Formula returns an empty string.


Paste Special conforms to that definition.

A quick fix might be to add this right after the paste special:

On Error Resume Next 'in case no constants
Selection.SpecialCells(xlCellTypeConstants).ClearC ontents
On Error GoTo 0


But you may want to take a look at David McRitchie's INSRTROW()
macro, too:

http://www.mvps.org/dmcritchie/excel/insrtrow.htm



In article ,
polletje wrote:

I created a macro to copy and paste the formulas from one row to
another. I dont want to copy the the values.
When I run it, it copys the formulas but ALSO the values. What am i
doing wrong? Can someone help me?

-------------------------------------------------------------------------
Application.Goto Reference:="totaal"
Selection.EntireRow.Insert
Application.Goto Reference:="totaal"
ActiveCell.Offset(-2, -35).Range("A1:AJ1").Select

Selection.Copy
Application.Goto Reference:="totaal"
ActiveCell.Offset(-1, -35).Range("A1:AJ1").Select

Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub

--------------------------------------------------------------------------

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default copy\paste with vba

polletje,
Just throw away the ActiveSheet.Paste-line


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default copy\paste with vba

Thanx,

the quick fix did the trick!!!


---
Message posted from http://www.ExcelForum.com/

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
Can't Copy and Paste or Paste Special between Excel Workbooks wllee Excel Discussion (Misc queries) 5 April 29th 23 03:43 AM
Copy, paste without file name referenced after paste AusTexRich Excel Discussion (Misc queries) 6 September 23rd 08 02:57 AM
Copy; Paste; Paste Special are disabled Mack Neff[_3_] Excel Discussion (Misc queries) 0 April 28th 08 06:29 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
I cannot paste from one workbook to another. Copy works, paste do. JimmyMc Excel Discussion (Misc queries) 1 June 10th 05 03:54 PM


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