A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Discussion (Misc queries)
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Macro for copy and paste values



 
 
Thread Tools Display Modes
  #1  
Old March 8th 08, 05:06 PM posted to microsoft.public.excel.misc
excelnerd
external usenet poster
 
Posts: 4
Default Macro for copy and paste values

Hi,

I am running the following macro for copying a number derived from a goal
seek function and pasting into another worksheet.


Dim A As String

A = Sheets("Sheets1").Range("A10").Value
Sheets("Sheets1").Range("A15").GoalSeek Goal:=A,
ChangingCell:=Sheets("Sheets2").Range("D10")

The macro works fine and my sheets2.D10 gets a value with 15 decimal places.
However, I want it to roundup to 2 decimal places by adding the roundup
function in the above macro. How can I do this?

A quick help would be greatly appreciated. Many thanks.
Ads
  #2  
Old March 8th 08, 05:10 PM posted to microsoft.public.excel.misc
Sean Timmons
external usenet poster
 
Posts: 1,696
Default Macro for copy and paste values

Range("D10").NumberFormat = "0.00"

"excelnerd" wrote:

> Hi,
>
> I am running the following macro for copying a number derived from a goal
> seek function and pasting into another worksheet.
>
>
> Dim A As String
>
> A = Sheets("Sheets1").Range("A10").Value
> Sheets("Sheets1").Range("A15").GoalSeek Goal:=A,
> ChangingCell:=Sheets("Sheets2").Range("D10")
>
> The macro works fine and my sheets2.D10 gets a value with 15 decimal places.
> However, I want it to roundup to 2 decimal places by adding the roundup
> function in the above macro. How can I do this?
>
> A quick help would be greatly appreciated. Many thanks.

  #3  
Old March 8th 08, 05:31 PM posted to microsoft.public.excel.misc
excelnerd
external usenet poster
 
Posts: 4
Default Macro for copy and paste values

This changes the number format only. But I want the cell itself to contain
only two decimal points. For example,

If Cell A * Cell B = Cell C and
I want to put a value 1000 to Cell C by changing Cell A. Cell A should
contain a number of only two decimal places, not a number like
10.459409908349.

Do you think it's possible?

"Sean Timmons" wrote:

> Range("D10").NumberFormat = "0.00"
>
> "excelnerd" wrote:
>
> > Hi,
> >
> > I am running the following macro for copying a number derived from a goal
> > seek function and pasting into another worksheet.
> >
> >
> > Dim A As String
> >
> > A = Sheets("Sheets1").Range("A10").Value
> > Sheets("Sheets1").Range("A15").GoalSeek Goal:=A,
> > ChangingCell:=Sheets("Sheets2").Range("D10")
> >
> > The macro works fine and my sheets2.D10 gets a value with 15 decimal places.
> > However, I want it to roundup to 2 decimal places by adding the roundup
> > function in the above macro. How can I do this?
> >
> > A quick help would be greatly appreciated. Many thanks.

  #4  
Old March 8th 08, 06:51 PM posted to microsoft.public.excel.misc
Gord Dibben
external usenet poster
 
Posts: 22,912
Default Macro for copy and paste values

ActiveCell.Value = Application.WorksheetFunction.Round(ActiveCell, 2)


Gord Dibben MS Excel MVP

On Sat, 8 Mar 2008 09:31:00 -0800, excelnerd
> wrote:

>This changes the number format only. But I want the cell itself to contain
>only two decimal points. For example,
>
>If Cell A * Cell B = Cell C and
>I want to put a value 1000 to Cell C by changing Cell A. Cell A should
>contain a number of only two decimal places, not a number like
>10.459409908349.
>
>Do you think it's possible?
>
>"Sean Timmons" wrote:
>
>> Range("D10").NumberFormat = "0.00"
>>
>> "excelnerd" wrote:
>>
>> > Hi,
>> >
>> > I am running the following macro for copying a number derived from a goal
>> > seek function and pasting into another worksheet.
>> >
>> >
>> > Dim A As String
>> >
>> > A = Sheets("Sheets1").Range("A10").Value
>> > Sheets("Sheets1").Range("A15").GoalSeek Goal:=A,
>> > ChangingCell:=Sheets("Sheets2").Range("D10")
>> >
>> > The macro works fine and my sheets2.D10 gets a value with 15 decimal places.
>> > However, I want it to roundup to 2 decimal places by adding the roundup
>> > function in the above macro. How can I do this?
>> >
>> > A quick help would be greatly appreciated. Many thanks.


 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy range in macro using paste special values Jeff Excel Discussion (Misc queries) 2 August 20th 07 08:12 PM
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
Macro to open workbook and copy and paste values in to orig workbo Dena X Excel Worksheet Functions 1 December 15th 05 11:13 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


All times are GMT +1. The time now is 01:35 PM.


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