Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Macro will copy formula instead of value

Hi Everyone
I've got this macro for a summary sheet but it's pasting the formulas and
formating that I don't want.
I tried different things but no success.
----------------------------------------------
Sub SummaryPlus()
'Increment invoice number
Sheets("Facture").Range("K2").Value =
Sheets("Facture").Range("K2").Value + 1
ThisWorkbook.Save (This works OK)<<
'Date
Sheets("Facture").Range("B4") = Date (This works OK)<<


'Find the last row and copy/paste information from Facture worksheet

'Invoice Number
lastrow = Sheets("Summary").Cells(Cells.Rows.Count, "A").End(xlUp).Row
Sheets("Facture").Range("K2").Copy _
Destination:=Sheets("Summary").Range("A" & lastrow + 1)
(This does not works OK)<<


'Customer Name
lastrow = Sheets("Summary").Cells(Cells.Rows.Count, "B").End(xlUp).Row
Sheets("Facture").Range("G1").Copy _
Destination:=Sheets("Summary").Range("B" & lastrow + 1)
(This does not works OK)<<


'Address
lastrow = Sheets("Summary").Cells(Cells.Rows.Count, "C").End(xlUp).Row
Sheets("Facture").Range("G2").Copy _
Destination:=Sheets("Summary").Range("C" & lastrow + 1)
(This does not works OK)<<


'Labor Cost
lastrow = Sheets("Summary").Cells(Cells.Rows.Count, "d").End(xlUp).Row
Sheets("Facture").Range("L37").Copy
Destination:=Sheets("Summary").Range("d" & lastrow + 1) (This does not works
OK)<<
End Sub
------------------------------------------------------------------
I tried this :lastrow = Sheets("Summary").Cells(Cells.Rows.Count,
"A").End(xlUp).Row
Sheets("Facture").Range("K2").Copy _
Destination:=Sheets("Summary").Range("A" & lastrow +
1).pastespecial _
paste:=xlpastevalues (It gives an error )

I tried this also :lastrow = Sheets("Summary").Cells(Cells.Rows.Count,
"A").End(xlUp).Row
Sheets("Facture").Range("K2").Copy _
Destination:=Sheets("Summary").Range("A" & lastrow +
1).value _
= workSheets("Facture").range("K2").value
--------------------------------------------------------------------
Can anyone help me please.

Cimjet


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Macro will copy formula instead of value

Try:
Sheets("Summary").Cells(lastrow + 1, "A").Value = _
Sheets("Facture").Range("K2").Value

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Macro will copy formula instead of value

Hi Garry
Thanks for taking the time to help me.
It's not working. It copies the info on the top line removing my heading and
will keep pasting on that same row. It's not stepping down each time I execute
the macro.
Regards
Cimjet
"GS" wrote in message ...
Try:
Sheets("Summary").Cells(lastrow + 1, "A").Value = _
Sheets("Facture").Range("K2").Value

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Macro will copy formula instead of value

If 'Source' value is Sheets("Facture").Range("K2").Value,
AND Sheets("Summary") is empty except for headings in Row1,
then this...

Sub CopyData()
Dim lLastRow As Long
With Sheets("Summary")
lLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Cells(lLastRow + 1, "A").Value = _
Sheets("Facture").Range("K2").Value
End With
End Sub

...puts the 'Source' value into Sheets("Summary").Range("A2")! Next
round it puts the value into 'A3', ..and so on.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Macro will copy formula instead of value

Slightly different approach if you want to increment rows continually
once the first blank row has been established..

Sub CopyData2()
Dim lNextRow As Long
With Sheets("Summary")
lNextRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
.Cells(lNextRow, "A").Value = Sheets("Facture").Range("K2").Value
lNextRow = lNextRow + 1
.Cells(lNextRow, "A").Value = Sheets("Facture").Range("K3").Value
lNextRow = lNextRow + 1
'..and so on
End With
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Macro will copy formula instead of value

Hi Garry
That did it, works perfect.
Thank you
Cimjet
"GS" wrote in message ...
If 'Source' value is Sheets("Facture").Range("K2").Value,
AND Sheets("Summary") is empty except for headings in Row1,
then this...

Sub CopyData()
Dim lLastRow As Long
With Sheets("Summary")
lLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Cells(lLastRow + 1, "A").Value = _
Sheets("Facture").Range("K2").Value
End With
End Sub

..puts the 'Source' value into Sheets("Summary").Range("A2")! Next
round it puts the value into 'A3', ..and so on.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Macro will copy formula instead of value

Cimjet pretended :
Hi Garry
That did it, works perfect.
Thank you
Cimjet


You're welcome! Always glad to help...

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


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 a Formula in a Macro KennyD Excel Discussion (Misc queries) 3 March 7th 10 01:04 AM
Copy down formula macro Eva Excel Worksheet Functions 3 December 9th 09 10:33 PM
Copy a formula down in a macro Sal Excel Discussion (Misc queries) 3 June 5th 06 02:52 AM
Copy Formula with a Macro J Excel Programming 4 August 24th 05 09:40 PM
Copy Formula Macro ME Pike Excel Programming 2 September 17th 03 09:42 PM


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