how do i merge down a sum of formulas into one function

jorgefilemon

New Member
Joined
May 9, 2014
Messages
9
ok i have written down this

=LEFT(A1,3)&MID(A1,FIND(" ",A1)+1,3)&MID(A1, FIND(" ",A1,FIND(" ",A1)+1)+1, 2)&RIGHT(A1,2)&TEXT(MONTH(TODAY()),"00")&RIGHT(YEAR(TODAY()),2)

i put these formulas together to generate SKU for my store.

I wanna turn this into a function named SKU(), for easy access in excel, how do i do this?


 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Welcome to the Board!

Can you give us an example of an entry into A1 so we have something to test?
 
Upvote 0
OK cool so I have a shoe store, so I have this:

brand model color size

A1 = BARALDI 4505666 BLACK 20

The formulas generates this:
BAR450BL200514

<colgroup><col></colgroup><tbody>
</tbody>

(the last four digits in the SKU are the date (month,year)when the product is uploaded to the system)
 
Upvote 0
OK. Here you go. I split each piece to its on separate line in the VB code to see more easily what each part does:
Code:
Function SKU(myEntry As String) As String

    SKU = Left(myEntry, 3) & _
          Mid(myEntry, InStr(myEntry, " ") + 1, 3) & _
          Mid(myEntry, InStr(InStr(myEntry, " ") + 1, myEntry, " ") + 1, 2) & _
          Right(myEntry, 2) & _
          Format(Date, "mmyy")
        
End Function
So, on an Excel sheet, if the item was in cell A1, you would just use:
=SKU(A1)
 
Upvote 0
Here is another UDF that should also work...

Code:
Function SKU(myEntry As String) As String
  SKU = Application.Replace(myEntry, 4, InStr(myEntry, " ") - 3, "")
  SKU = Left(Application.Replace(SKU, 7, InStr(SKU, " ") - 6, ""), 8) & Split(myEntry)(3) & Format(Date, "mmyy")
End Function
 
Upvote 0
hi guys, thanks for your help, it's working great!.

how do I save my costum function so it's always shown in the functions menu in every workbook?

I read microsoft instructions, and I did what they said, but i just can't make it shown in the "more functions…" menu in any other workbook. I'm on mac btw.





MICROSOFT INSTRUCTIONS
An easier way to make your custom functions available at all times is to store them in a separate workbook and then save that workbook as an add-in (an XLA file) in your XLStart folder. (The XLStart folder is a subfolder of the folder containing your Excel files. When you start Excel, the program opens any documents it finds in XLStart.) To save a workbook as an add-in, choose File, Save As (or File, Save). Then choose Microsoft Excel Add-in from the Files Of Typelist.
If your user-defined functions are stored in an XLA file that is present in memory, you don't have to specify the name of that file when you call a function. If the XLA file is saved in your XLStart folder, it will be present in memory whenever you run Excel.
 
Upvote 0
I read microsoft instructions, and I did what they said, but i just can't make it shown in the "more functions…" menu in any other workbook. I'm on mac btw.
I do not have access to a Mac, so I have no way to test anything I might come up with (unfortunately, there are differences between the PC and Mac worlds). Wait to see if someone with knowledge of the Mac world comes along... if not, start a new thread and mention in the thread's title that you are seeking a Mac solution so the "right" people can react to your question.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,731
Members
448,987
Latest member
marion_davis

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