Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Divide Value in Cell by worksheet count

I need to have a macro that will take look at a cell ("A1") then divide
that by the number of worksheets. So if I have 200 in cell A1 on
worksheet 3 it would be 200/3. Then on worksheet 4 it would be 200/4
and so on.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Divide Value in Cell by worksheet count

First enter this small UDF:

Function whereami()
s = Application.Caller.Parent.Name
For i = 1 To Sheets.Count
If Sheets(i).Name = s Then
whereami = i
Exit Function
End If
Next
End Function


It will return the number of the sheet on which it is entered. So if cell
A1 on any sheet contains 200, then:

=A1/whereami()

will give you your desired result.
--
Gary's Student


"newguy" wrote:

I need to have a macro that will take look at a cell ("A1") then divide
that by the number of worksheets. So if I have 200 in cell A1 on
worksheet 3 it would be 200/3. Then on worksheet 4 it would be 200/4
and so on.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Divide Value in Cell by worksheet count

This one works with the active sheet and is run from the standard VBA module.

Sub divWs()
MyInt = ActiveSheet.Index
MyVal = Range("$A$1") / MyInt
MsgBox "Result is " & MyVal
End Sub

"newguy" wrote:

I need to have a macro that will take look at a cell ("A1") then divide
that by the number of worksheets. So if I have 200 in cell A1 on
worksheet 3 it would be 200/3. Then on worksheet 4 it would be 200/4
and so on.


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
How do you divide all values in the worksheet by 1000000 me Excel Worksheet Functions 1 April 25th 05 04:29 AM
Divide one row over other row I dont wont to divide one number Rick Excel Discussion (Misc queries) 0 March 4th 05 07:13 PM
Divide by a count to give daily, monthly, quarterly results mtwelsh72 Excel Programming 1 January 23rd 05 11:46 PM
Divide up Worksheet HilcrRWise Excel Programming 1 August 17th 04 09:21 PM
Divide Expression stops in Macro when Can't divide JUAN Excel Programming 6 May 6th 04 07:05 AM


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

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"