SOLVED! Function as Macro

ROBINSYN

Board Regular
Joined
Aug 19, 2002
Messages
188
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
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
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
Joined
Aug 19, 2002
Messages
188
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
Joined
Aug 19, 2002
Messages
188
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
Joined
Aug 19, 2002
Messages
188

ADVERTISEMENT

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?
 

Ivan F Moala

MrExcel MVP
Joined
Feb 10, 2002
Messages
4,209
Have a look in the VBA Editor
Lookup Application.Worksheetfunction

This is how you would need to code it in VBA
 

ROBINSYN

Board Regular
Joined
Aug 19, 2002
Messages
188
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
Joined
Aug 19, 2002
Messages
188
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,207
Messages
5,594,841
Members
413,944
Latest member
3xc3ln00b

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Top