Formula Question in Macro

helpme20

Board Regular
Joined
Aug 28, 2010
Messages
102
my end goal is thatevery month you run the macro and get : "**this month** pricing" and"**next month** pricing"



I get an #Name error when I run this.

=MONTHNAME()&" Price"


Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("U1").Select
ActiveCell.FormulaR1C1 = "=MONTHNAME()+30&"" Price"""
Range("Q1").Select
ActiveCell.FormulaR1C1 = "=MONTHNAME()&"" Price"""
Range("U1").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]=""Call for Pricing"",RC[-1],RC[-2])"
 
Last edited:

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
MONTHNAME is a VBA function, not a spreadsheet function. Also you haven't given it any parameters.

An equivalent formula that can be used in the spreadsheet, where A1 (in this sample) holds your month number.
=TEXT(A1*29,"mmmm")
 
Upvote 0
MONTHNAME is a VBA function, not a spreadsheet function. Also you haven't given it any parameters.

An equivalent formula that can be used in the spreadsheet, where A1 (in this sample) holds your month number.
=TEXT(A1*29,"mmmm")

Any other suggestions?
 
Upvote 0
I know that the excerpt was from a macro. My point is that you can't put a formula into a spreadsheet that contains non-spreadsheet functions (unless you write a UDF for it). That's why I offered an alternative formula for you to use in your macro. Adapt that formula as necessary.
 
Last edited:
Upvote 0
Perhaps.
Code:
Range("U1").Value = MonthName(Month(Now)+1) & " Price"
Range("Q1").Value = MonthName(Month(Now)) & " Price"
Range("U1").FormulaR1C1 = "=IF(RC[-1]=""Call for Pricing"",RC[-1],RC[-2])"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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
Back
Top