Change this VBA to a Formula. HELP PLEASE

Mister H

Well-known Member
Joined
Mar 6, 2002
Messages
1,507
Hi:

I am trying to change this code to a formula but I am not having any luck. This is the code that I have that names a file but I need the name to go in a specific cell (titled FileName) as well.

Code:
ActiveSheet.Range("Min") & " - " & ActiveSheet.Range("LocationNo") & " - " & ActiveSheet.Range("LocationName") & " - " & Format(ActiveSheet.Range("TransactionDate"), "dd-mmm-yyyy") & "   " & Format(ActiveSheet.Range("TotalRevenue"), "$###,###,##0.00")

So, I tried this but I can't get it to work for me:

=UPPER(TEXT(Min & " - " & LocationNo & " - " & LocationName & " - " & Format(TransactionDate, "dd-mmm-yyyy") & " " & Format(TotalRevenue,"$###,###,##0.00")))

Min
LocationNo
LocationName
TransactionDate
TotalRevenue

These are all named cells within the workbook.

Can someone help me out please? :confused:

THANKS,
Mark
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi,

You can not reference a named range as a string, which is exactly what you are trying to do. The TEXT() function will convert your attempt in referencing the named cell Min into the string "Min" which won't give you the desired result.
I can give you some hints regarding using named ranges in formulas.

Try this very simple example:

In a new sheet I name cell A1 as cellone and cell A2 as celltwo.
I put values cellone = 1 and celltwo = 2
In e.g. cell B1 I enter the formula: =SUM(cellone;celltwo) which would evaulate to the value 3.

As you can see I'm NOT writing =SUM("cellone";"celltwo").

BR,
perco

He
 
Upvote 0
THANKS to BOTH of you for your help. Here is the formula that seems to be working:

=UPPER(Min & " - " & LocationNo & " - " & LocationName & " - " & TEXT(TransactionDate, "dd-mmm-yyyy") & " " & TEXT(TotalRevenue,"$###,###,##0.00"))

Have a GREAT day,
Mark :)
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,726
Members
452,939
Latest member
WCrawford

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