Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default VBA or Macro solution to convert Percentages to decimals

Hi all

I have a few hundred excel files which have percentage data in them. I
want to replace that percentage data into a decimal value rounded to
two decimal points.

For example:

15.345000021 (which appears as 15% in the cell) to 15.35

What I would like to do is to open each excel file, highlight all the
cells with percentage values, and apply a macro which will do this
transformation, instead of doing it manually column by column.

I would be very grateful if anyone could guide me to do this.

Thanks
Yousaf

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default VBA or Macro solution to convert Percentages to decimals

One way:

Public Sub PercentsToDecimal()
Dim rCell As Range
For Each rCell In ActiveSheet.UsedRange.Cells
With rCell
If .NumberFormat Like "*%*" Then
.Value = Application.Round(.Value * 100, 2)
.NumberFormat = "0.00"
End If
End With
Next rCell
End Sub


In article .com,
"Zuzeppeddu" wrote:

Hi all

I have a few hundred excel files which have percentage data in them. I
want to replace that percentage data into a decimal value rounded to
two decimal points.

For example:

15.345000021 (which appears as 15% in the cell) to 15.35

What I would like to do is to open each excel file, highlight all the
cells with percentage values, and apply a macro which will do this
transformation, instead of doing it manually column by column.

I would be very grateful if anyone could guide me to do this.

Thanks
Yousaf

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default VBA or Macro solution to convert Percentages to decimals

Thanks so much. It works!

On Mar 19, 2:36 pm, JE McGimpsey wrote:
One way:

Public Sub PercentsToDecimal()
Dim rCell As Range
For Each rCell In ActiveSheet.UsedRange.Cells
With rCell
If .NumberFormat Like "*%*" Then
.Value = Application.Round(.Value * 100, 2)
.NumberFormat = "0.00"
End If
End With
Next rCell
End Sub

In article .com,



"Zuzeppeddu" wrote:
Hi all


I have a few hundred excel files which have percentage data in them. I
want to replace that percentage data into a decimal value rounded to
two decimal points.


For example:


15.345000021 (which appears as 15% in the cell) to 15.35


What I would like to do is to open each excel file, highlight all the
cells with percentage values, and apply a macro which will do this
transformation, instead of doing it manually column by column.


I would be very grateful if anyone could guide me to do this.


Thanks
Yousaf- Hide quoted text -


- Show quoted text -



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
I am looking for a solution to convert a pdf to excel dcraig Excel Discussion (Misc queries) 1 March 6th 09 12:26 AM
How do I convert 4'6" into decimals? Curious Excel Worksheet Functions 2 November 14th 06 11:34 PM
Convert VBA solution to a formula Toppers Excel Discussion (Misc queries) 2 June 22nd 06 09:45 PM
Rounding percentages problem need a solution for jimtmcdaniels Excel Discussion (Misc queries) 2 April 27th 06 08:22 AM


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