Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do you divide all values in the worksheet by 1000000 | Excel Worksheet Functions | |||
Divide one row over other row I dont wont to divide one number | Excel Discussion (Misc queries) | |||
Divide by a count to give daily, monthly, quarterly results | Excel Programming | |||
Divide up Worksheet | Excel Programming | |||
Divide Expression stops in Macro when Can't divide | Excel Programming |