جرب هل هدا ما تقصده
Option Explicit
Sub Split_names()
Dim tbl&, tmp&, i&, Max&, c&, j&, lr&, r&, s&
Dim n As String, ky As Boolean, ColArr As Range, OnRng As Range
Dim Arr As Variant, rng As Variant, sp As Variant, Choisir As VbMsgBoxResult
Dim WS As Worksheet: Set WS = Sheets("حساب الفوائد")
Dim dest As Worksheet: Set dest = Sheets("مؤشر الفائدة")
Dim ColNam As String: ColNam = "DM"
Choisir = MsgBox("تحديث البيانات ؟", vbYesNo + vbQuestion, "تأكيد")
If Choisir <> vbYes Then Exit Sub
Max = 444
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
.ErrorCheckingOptions.BackgroundChecking = True
End With
On Error Resume Next
tbl = WS.Columns("T:CC").Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
On Error GoTo 0
tbl = WorksheetFunction.Min(WorksheetFunction.Max(tbl, 14), Max)
WS.Range("DJ14:DJ" & tbl).ClearContents
Set OnRng = WS.Range("T14:CC" & tbl)
Arr = OnRng.Value
For tmp = 1 To UBound(Arr, 1)
n = ""
ky = False
For i = 1 To UBound(Arr, 2)
If Arr(tmp, i) <> "" Then
n = IIf(n = "", WS.Cells(dest.Range("AT6").Value, i + 19).Text, n & "*" & WS.Cells(dest.Range("AT6").Value, i + 19).Text)
If Not ky Then
WS.Cells(tmp + 13, 114).NumberFormat = WS.Cells(tmp + 13, i + 19).NumberFormat
ky = True
End If
End If
Next i
WS.Cells(tmp + 13, 114).Value = n
Next tmp
On Error Resume Next
Set ColArr = WS.Range("DG14:DG" & tbl).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not ColArr Is Nothing Then
Arr = ColArr.Value
ReDim rng(1 To UBound(Arr, 1), 1 To 1)
For c = 1 To UBound(Arr, 1)
rng(c, 1) = Arr(c, 1)
Next c
WS.Range("DM14").Resize(UBound(rng, 1), 1).Value = rng
End If
dest.Range("AS2") = 2
dest.Range("I6:AL105").ClearContents
lr = WS.Cells(WS.Rows.Count, ColNam).End(xlUp).Row
WS.Range("DN14:EQ" & WS.Rows.Count).ClearContents
Arr = WS.Range(ColNam & "14:" & ColNam & lr).Value
For j = 1 To UBound(Arr, 1)
sp = Split(Arr(j, 1), "*")
For r = LBound(sp) To UBound(sp)
WS.Cells(j + 13, r + 118).NumberFormat = "@"
WS.Cells(j + 13, r + 118).Value = sp(r)
Next r
Next j
For s = 9 To 38
dest.Columns(s).EntireColumn.Hidden = (dest.Cells(5, s).Value = 0)
Next s
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.ErrorCheckingOptions.BackgroundChecking = False
End With
End Sub
نسب ومؤشر الفائدة v4.xlsb