Help with Creating a Function

jpfulton

New Member
Joined
Sep 16, 2008
Messages
16
I'm trying to figure out how to turn the following into a function:
Code:
=IF(AND(G2<>"",F2<>""),CONCATENATE(F2,"; ",G2),CONCATENATE(F2,G2))
Rather than referencing G2 and F2 I'd like the function to automatically reference the cell two to the left and one to the left respectively. Any help is appreciated!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
How about
Code:
Function jpfulton() As String
   Dim Cl As Range
   Application.Volatile
   Set Cl = Range(Application.Caller.Address)
   jpfulton = Cl.Offset(, -1) & "; " & Cl.Offset(, -2)
   If Cl.Offset(, -1) = "" Or Cl.Offset(, -2) = "" Then
      jpfulton = Replace(jpfulton, "; ", "")
   End If
End Function
 
Upvote 0
I made one tiny tweak and it's perfect (it was concatenating the fields in the wrong order). Thank you!!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,225,743
Messages
6,186,770
Members
453,370
Latest member
juliewar

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