Compile Error: Expected End Sub when using the following code to transpose and insert puntuation please help

mukun

New Member
Joined
Oct 14, 2015
Messages
16
I am using the code below which i got off this website in excel 2010.

When I try running the macros gives me the "compile error: expected end sub".

I am new to this.

Please help.

Sub Transfer()
Function konkat(ByVal r As Range, Optional s As String = ",")
For Each c In r
konkat = konkat & c.Value & s
Next
konkat = Left(konkat, Len(konkat) - Len(s))
End Function
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I am trying to achieve this

A1:A8 = the digits 1 to 8

=konkat(A1:A8) returns[TABLE="width: 56"]
<colgroup><col width="56" style="width: 42pt;"></colgroup><tbody>[TR]
[TD="width: 56, bgcolor: transparent"]1,2,3,4,5,6,7,8[/TD]
[/TR]
</tbody>[/TABLE]


=konkat(A1:A8,"/") returns
[TABLE="width: 56"]
<colgroup><col width="56" style="width: 42pt;"></colgroup><tbody>[TR]
[TD="width: 56, bgcolor: transparent"]1/2/3/4/5/6/7/8

[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Welcome to the board.

Your code as 2 declaration lines, one for a Sub, then one for a Function

Rich (BB code):
Sub Transfer()
Function konkat(ByVal r As Range, Optional s As String = ",")
    For Each c In r
        konkat = konkat & c.Value & s
    Next
    konkat = Left(konkat, Len(konkat) - Len(s))
End Function
 
Last edited:
Upvote 0
Remove the Sub Transfer() line

Edit: toooooo slow
 
Upvote 0
solved! appreciate the speed of response and the effectiveness!!!!

yes i realise my edit was slow lol. didnt know thats a thing.

thanks again
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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