Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Create a marcro that changes number of decimal places in a field according to specified criteria

Hi people, hope you can help me

I need a macro to do the following:

1. A1 contains a value - 2 (which determines the number of decimal places
2. A2 contains a value - 10
3. A3 gives the results - i.e A1 is number of decimal places for A2 therefore = 1.0

Can this be done

Thank you for your help

Hayley
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Create a marcro that changes number of decimal places in a field according to specified criteria

Hayley,

it can be done, but is there any reason why this would
have to be done with a macro?

The easiest way would just be to have a formula dividing
A2 by 10 to A1-th power like this:

=A2/(10^A1)

The equivalent in VBA would be something like:

Cells(3,1).value = cells(2,1).value/(10 ^ Cells(1,1).value)

Cheers, Pete

-----Original Message-----
Hi people, hope you can help me.

I need a macro to do the following:-

1. A1 contains a value - 2 (which determines the number

of decimal places)
2. A2 contains a value - 104
3. A3 gives the results - i.e A1 is number of decimal

places for A2 therefore = 1.04

Can this be done?

Thank you for your help.

Hayley
.

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
Chart Number Decimal Places John Excel Discussion (Misc queries) 6 July 2nd 09 08:17 PM
Split number with decimal places into 2 columns meridklt New Users to Excel 3 May 3rd 07 12:00 AM
how to count the number of decimal places in a cell? Warren Smith Excel Worksheet Functions 7 August 28th 05 01:52 PM
Converting a number to 2 decimal places mattslav Excel Discussion (Misc queries) 2 June 4th 05 04:10 AM
Number Format Issues-Decimal Places EXCELNCBOY Excel Worksheet Functions 1 November 4th 04 10:41 PM


All times are GMT +1. The time now is 04:33 AM.

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

About Us

"It's about Microsoft Excel"