Hi Friends,
I need a help in a scenario. I am applying a function to concatenate a column range. However when I run the main code, it stucks in that function instead of running the main code.
I have add code of concatenate function in a module and add another main code to run in another module. In main code, there is no any path given to go to function code still it doesnot go further and stucks into Function when I am testing by pressing F8.
Please suggest with the required correction. I am mentioning both the code below.
Concatenate function code:
Main Code
I need a help in a scenario. I am applying a function to concatenate a column range. However when I run the main code, it stucks in that function instead of running the main code.
I have add code of concatenate function in a module and add another main code to run in another module. In main code, there is no any path given to go to function code still it doesnot go further and stucks into Function when I am testing by pressing F8.
Please suggest with the required correction. I am mentioning both the code below.
Concatenate function code:
Code:
Function CONCATENATEMULTIPLE(Ref As Range, Separator As String) As String
Dim Cell As Range
Dim Result As String
For Each Cell In Ref
Result = Result & Cell.Value & Separator
Next Cell
CONCATENATEMULTIPLE = Left(Result, Len(Result) - 1)
End Function
Main Code
Code:
Sub AssignCourse()
'
'
'Opening Unipart File
Dim TWK As Workbook
Dim Mypath As String
Dim namfil As String
Set TWK = ThisWorkbook
Mypath = TWK.Sheets("Main").Range("CA1").Value
namfil = TWK.Sheets("Main").Range("CB1").Value
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.EnableEvents = False
End With
ThisWorkbook.Activate
Sheet1.Select
Sheet1.Unprotect Password:="Vodafone"
Sheet1.Range("BO2:BW100000").ClearContents
Sheet1.Select
Mypath = Sheet1.Range("CA1").Value
Workbooks.Open Filename:=Mypath
NwFile = ActiveWorkbook.Name
shname = ActiveSheet.Name
Sheets(shname).Name = "Data"
Sheets("Data").Activate
ActiveSheet.Select
Columns("A:Z").ColumnWidth = 20
Range("A2").Select
Range("A2:A65536").Select
Selection.Copy
ThisWorkbook.Activate
Sheet1.Select
Range("BQ2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Windows(NwFile).Close
ThisWorkbook.Activate
Sheet1.Select
Range("BU2").Select
MYRW = Sheet1.Range("BQ1048576").End(xlUp).Row
MARW = Sheet1.Range("BQ1048576").End(xlUp).Row
Range("BP2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(VLOOKUP(RC[1],Database!C[-67]:C[-65],3,0),"""")"
Range("BO2").Select
ActiveCell.FormulaR1C1 = _
"=IF(AND(RC[1]="""",R[1]C[1]=""""),"""",IF(AND(RC[1]<>"""",R[1]C[1]=""""),RC[1],RC[1]&""; ""))"
Range("BR2").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(VLOOKUP(RC[-1],Database!C[-69]:C[-67],3,0),"""")"
Range("BW2").Select
ActiveCell.FormulaR1C1 = "=RC[-1]-RC[-2]"
Range("BU2").Select
ActiveCell.FormulaR1C1 = "=R2C62"
Range("BS2").Value = Range("L13").Value
Range("BB1").Value = Range("L13").Value
Range("BV2").Value = Range("L15").Value
Range("BT2").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-1],Database!C9:C10,2,0),"""")"
Range("BO2").Select
Selection.AutoFill Destination:=Range("BO2:BO" & MYRW)
Range("BP2").Select
Selection.AutoFill Destination:=Range("BP2:BP" & MYRW)
Range("BR2").Select
Selection.AutoFill Destination:=Range("BR2:BR" & MYRW)
Range("BS2").Select
Selection.AutoFill Destination:=Range("BS2:BS" & MYRW)
Range("BT2").Select
Selection.AutoFill Destination:=Range("BT2:BT" & MYRW)
Range("BU2").Select
Selection.AutoFill Destination:=Range("BU2:BU" & MYRW)
Range("BV2").Select
Selection.AutoFill Destination:=Range("BV2:BV" & MYRW)
Range("BW2").Select
Selection.AutoFill Destination:=Range("BW2:BW" & MYRW)
Range("BO2:BW" & MYRW).Copy
Range("BO2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("BQ2:BW" & MYRW).Copy
Sheet2.Select
Range("A" & Cells.Rows.Count).End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheet1.Select
'FrmValue = InputBox("Enter the Sender Email ID ", "Vodafone University Course Allocation", 1)
'Sheet1.Range("BB4") = FrmValue
Range("BB4").Select
ActiveCell.FormulaR1C1 = "=CONCATENATEMULTIPLE(R[-1]C[13]:R[1997]C[13],"" "")"
Range("BB4").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Call Email_Syndicate
End Sub
Last edited: