# SOLVED! Function as Macro

#### ROBINSYN

##### Board Regular
Can I create a macro for a function.

=MAX(Z:Z)+1

The macro needs to select workbook"New Purchase Order" Sheetname"Purchase Order"

Then perform the function.

Can this be done?
This message was edited by ROBINSYN on 2002-10-27 16:44
This message was edited by ROBINSYN on 2002-10-27 22:05
This message was edited by ROBINSYN on 2002-10-28 07:21

### Excel Facts

If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

#### Joe Was

##### MrExcel MVP
This is how to code the function in a macro:

ActiveCell.FormulaR1C1 = "=MAX(C[25])+1"

But, I do not know what you really want, I did not understand your note?

Do you want the macro in one WorkBook, that opens another WorkBook and go's to a Sheet in that newly opened WorkBook and does what with your function? JSW

#### ROBINSYN

##### Board Regular
Macro is in 1 Workbook. I have another macro that copies sheet 1 and creates a new workbook from the copied sheet. once that happens I want to save and close new workbook created,then return to 1st workbook then perform function.
This message was edited by ROBINSYN on 2002-10-27 01:02

#### ROBINSYN

##### Board Regular
Would it work like this? Or do I need to use worksheetname too?

Sub ponumber()

If max Then
Cells("K8") = (max("Z:Z") + 1)
End If
End Sub

#### ROBINSYN

##### Board Regular

if adding functions to macro is not possible. Is there a way I could have the macro run the function in a certain cell after sheet activation?

#### ROBINSYN

##### Board Regular
Joe. Can the above function work?

#### ROBINSYN

##### Board Regular

You can email me too if you have an example in workbook.
SynDee@sympatico.ca

#### Ivan F Moala

##### MrExcel MVP
Have a look in the VBA Editor
Lookup Application.Worksheetfunction

This is how you would need to code it in VBA

#### ROBINSYN

##### Board Regular
Trying but can't seem to get the handle on this.

Result is suppose to go in cell K8

Set myrange = Worksheets("Purchase Order").Range("k8")
Set WorksheetFunction = xlMax
Application.WorksheetFunction.Max (("Z:Z") + 1)

#### ROBINSYN

##### Board Regular
Please help! I don't understand how this increases the value of cell"K8" based on Column "Z" . Both column and cell are located on Worksheet"Purchase Order"

ActiveCell.FormulaR1C1 = "=MAX(C[25])+1"
This message was edited by ROBINSYN on 2002-10-27 22:08

Replies
6
Views
577
Replies
1
Views
369
Replies
8
Views
150
Replies
5
Views
283
Replies
0
Views
223

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,163,543
Messages
5,832,356
Members
430,128
Latest member
ojl987

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back