PC Review


Reply
Thread Tools Rate Thread

copy only value and not formula

 
 
ramzi
Guest
Posts: n/a
 
      28th Jul 2008
hi,

Below is my macro....
if my data only at A1 to A3, but A4 and A5 still have program (e.g =b4*b5),
how to copy only value (data) without copy the formula inside A4 and A5. So
for the next copy , it will start paste at E4 instead of E6.


Range("A1:A5").Select
Selection.Copy
Range("E1").Select
lastrow = Sheets("sheet1").Cells(Cells.Rows.Count, "E").End(xlUp).Row + 1
Sheets("Sheet1").Range("e" & lastrow).PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("C7").Select
Application.CutCopyMode = False

rgds
Ramzi
 
Reply With Quote
 
 
 
 
Greg Wilson
Guest
Posts: n/a
 
      28th Jul 2008
Don't know what you're trying to do, but this does pretty much what your
macro does without the selection and PasteSpecial. Maybe it's a step in the
right direction?

Sub Test()
Dim rw As Long
rw = Cells(Rows.Count, 5).End(xlUp).Row + 1
With Range("A1:A5")
.Value = .Value
Cells(rw, 5).Resize(5, 1).Value = .Value
End With
End Sub

Greg




"ramzi" wrote:

> hi,
>
> Below is my macro....
> if my data only at A1 to A3, but A4 and A5 still have program (e.g =b4*b5),
> how to copy only value (data) without copy the formula inside A4 and A5. So
> for the next copy , it will start paste at E4 instead of E6.
>
>
> Range("A1:A5").Select
> Selection.Copy
> Range("E1").Select
> lastrow = Sheets("sheet1").Cells(Cells.Rows.Count, "E").End(xlUp).Row + 1
> Sheets("Sheet1").Range("e" & lastrow).PasteSpecial Paste:=xlPasteValues,
> Operation:=xlNone, SkipBlanks _
> :=False, Transpose:=False
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False
> Range("C7").Select
> Application.CutCopyMode = False
>
> rgds
> Ramzi

 
Reply With Quote
 
Greg Wilson
Guest
Posts: n/a
 
      28th Jul 2008
Sorry, I missed the "Sheet1" qualification. This assumes that the transfer of
data to column E is on a different sheet (Sheet1 in this case):

Sub Test()
Dim rw As Long
rw = Sheets("Sheet1").Cells(Rows.Count, 5).End(xlUp).Row + 1
With Range("A1:A5")
.Value = .Value
Sheets("Sheet1").Cells(rw, 5).Resize(5, 1).Value = .Value
End With
End Sub

Greg
 
Reply With Quote
 
Greg Wilson
Guest
Posts: n/a
 
      28th Jul 2008
I think I figured out what you meant. This is a second attempt. The code
assumes the source range is hard coded as A1:A5. However, you can change it
to a selected cell range instead. See the commented out line.

Sub Test2()
Dim r As Range, c As Range
Dim rw As Long
rw = Sheets("Sheet1").Cells(Rows.Count, 5).End(xlUp).Row + 1
'Set r = Selection.SpecialCells(xlCellTypeConstants)
Set r = Range("A1:A5").SpecialCells(xlCellTypeConstants)
For Each c In r.Cells
Sheets("Sheet1").Cells(rw, 5).Value = c.Value
rw = rw + 1
Next
Set c = Nothing: Set r = Nothing
End Sub

Greg

"ramzi" wrote:

> hi,
>
> Below is my macro....
> if my data only at A1 to A3, but A4 and A5 still have program (e.g =b4*b5),
> how to copy only value (data) without copy the formula inside A4 and A5. So
> for the next copy , it will start paste at E4 instead of E6.
>
>
> Range("A1:A5").Select
> Selection.Copy
> Range("E1").Select
> lastrow = Sheets("sheet1").Cells(Cells.Rows.Count, "E").End(xlUp).Row + 1
> Sheets("Sheet1").Range("e" & lastrow).PasteSpecial Paste:=xlPasteValues,
> Operation:=xlNone, SkipBlanks _
> :=False, Transpose:=False
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False
> Range("C7").Select
> Application.CutCopyMode = False
>
> rgds
> Ramzi

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel formula to copy/paste formula needed please. colwyn Microsoft Excel Misc 4 22nd Oct 2008 11:27 PM
copy formula result (text) only - without copying formula Mulberry Microsoft Excel Misc 2 2nd Oct 2008 09:51 AM
I copy a formula and the results copy from the original cell =?Utf-8?B?YnJvb2tseW5zZA==?= Microsoft Excel Misc 1 23rd Jun 2007 01:35 AM
copy formula down a column and have cell references change within formula brad Microsoft Excel New Users 5 13th May 2007 04:38 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values =?Utf-8?B?RGVubmlz?= Microsoft Excel Misc 10 2nd Mar 2006 10:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:31 AM.