Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro to calculate percentage

i have attached a small spreadsheet

in yellow column i need percentage (for example G5/G11) but the proble
is that number of rows keep changing like instead of G11 it can b
G100,G500

another problem is that i want persentage column in column J becos th
columns can go upto I

please suggest
i will be thankful to u al

Attachment filename: book12.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=53213
--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default macro to calculate percentage

Hi Vikram,

Try this
Sub Percentages()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "G").End(xlUp).Row
For i = 5 To iLastRow - 1
If Cells(i, "G").Value < "" Then
With Cells(i, "J")
.Formula = "=G" & i & "/G" & iLastRow
.NumberFormat = "0.0%"
End With
End If
Next i
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"vikram " wrote in message
...
i have attached a small spreadsheet

in yellow column i need percentage (for example G5/G11) but the problem
is that number of rows keep changing like instead of G11 it can be
G100,G500

another problem is that i want persentage column in column J becos the
columns can go upto I

please suggest
i will be thankful to u all

Attachment filename: book12.xls
Download attachment:

http://www.excelforum.com/attachment.php?postid=532130
---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro to calculate percentage

thank u so much for ur help

i forgoit to tell u something in that
the problem is that even column keeps changing
like u told me for G but sometimes it is E or F

what do u suggest
i appreciate ur help so muc

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default macro to calculate percentage

to cater for it needs a rule What is the rule that determines whether it is
E, F or G?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"vikram " wrote in message
...
thank u so much for ur help

i forgoit to tell u something in that
the problem is that even column keeps changing
like u told me for G but sometimes it is E or F

what do u suggest
i appreciate ur help so much


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro to calculate percentage

it is a pivot and it the columns in that pivot keeps changing.....so
want that whwtever is the last range cell....which is always a total o
which we calculate percentage

and percentage column should remain J


thank u so muc

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default macro to calculate percentage

Maybe this will work it

Sub Percentages()
Dim iLastRow As Long
Dim iLastCol As Long
Dim i As Long

iLastCol = Cells(4, Columns.Count).End(xlToLeft).Column
iLastRow = Cells(Rows.Count, iLastCol).End(xlUp).Row
For i = 5 To iLastRow - 1
If Cells(i, iLastCol).Value < "" Then
With Cells(i, "J")
.FormulaR1C1 = "=RC" & iLastCol & "/R" & iLastRow & "C" &
iLastCol
.NumberFormat = "0.0%"
End With
End If
Next i
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"vikram " wrote in message
...
it is a pivot and it the columns in that pivot keeps changing.....so i
want that whwtever is the last range cell....which is always a total on
which we calculate percentage

and percentage column should remain J


thank u so much


---
Message posted from http://www.ExcelForum.com/



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
Calculate percentage Tony Murray Excel Discussion (Misc queries) 3 September 6th 09 11:37 PM
calculate percentage?? Learn[_2_] Excel Worksheet Functions 2 April 25th 09 05:12 AM
How do I Calculate a percentage Killerwatt Excel Discussion (Misc queries) 4 October 15th 08 06:08 AM
calculate percentage JP Excel Worksheet Functions 6 March 2nd 05 02:34 PM
Forumla to calculate a percentage julie regan Excel Discussion (Misc queries) 0 January 20th 05 07:53 PM


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