ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating function (https://www.excelbanter.com/excel-programming/395471-creating-function.html)

gjmink

Creating function
 
Hi all
I was trying to create a function to emulate the CONCATENATE function so as
not to have fill in every time I need it.
This is the code I have so far
Function InvFileName()
firstfield = 0
secondfield = ActiveCell.Offset(0, -2).Value
thirdfield = " "
fourthfield = ActiveCell.Offset(0, -5).Value
fifthfield = " - "
sixthfield = ActiveCell.Offset(0, -6).Value
InvFileName = CONCATENATE(firstfield, secondfield, thirdfield, fourthfield,
fifthfield, sixthfield)

Please advise what I need to do to tweek this to make it work.

Thanks for any and all help!
--
Have a great day and a better tomorrow!

Trevor Shuttleworth

Creating function
 
One way:

Function InvFileName()
firstfield = 0
secondfield = ActiveCell.Offset(0, -2).Value
thirdfield = " "
fourthfield = ActiveCell.Offset(0, -5).Value
fifthfield = " - "
sixthfield = ActiveCell.Offset(0, -6).Value
InvFileName = firstfield & secondfield & thirdfield & _
fourthfield & fifthfield & sixthfield
End Function

or just

Function InvFileName()
InvFileName = 0 & _
ActiveCell.Offset(0, -2).Value & _
" " & _
ActiveCell.Offset(0, -5).Value & _
" - " & _
ActiveCell.Offset(0, -6).Value
End Function

Regards

Trevor


"gjmink" wrote in message
...
Hi all
I was trying to create a function to emulate the CONCATENATE function so
as
not to have fill in every time I need it.
This is the code I have so far
Function InvFileName()
firstfield = 0
secondfield = ActiveCell.Offset(0, -2).Value
thirdfield = " "
fourthfield = ActiveCell.Offset(0, -5).Value
fifthfield = " - "
sixthfield = ActiveCell.Offset(0, -6).Value
InvFileName = CONCATENATE(firstfield, secondfield, thirdfield,
fourthfield,
fifthfield, sixthfield)

Please advise what I need to do to tweek this to make it work.

Thanks for any and all help!
--
Have a great day and a better tomorrow!





All times are GMT +1. The time now is 01:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com