Nhờ giúp tạo macro in theo list hồ sơ, có quy định sheet in theo mỗi số thứ tự

Liên hệ QC

diennv50

Thành viên mới
Tham gia
27/8/09
Bài viết
22
Được thích
0
Mình muốn tạo macro in list hồ sơ theo thứ tự từ a đến b, kèm theo điều kiện để chọn sheet in theo yêu cầu.
 

File đính kèm

  • 8. BBNT.xlsm
    1.4 MB · Đọc: 55
Mình muốn tạo macro in list hồ sơ theo thứ tự từ a đến b, kèm theo điều kiện để chọn sheet in theo yêu cầu.
Bạn tham khảo thử
Mã:
Sub InBB()
    Dim Rng As Range, Cll As Range, SoBB As String
With Sheet1
    Set Rng = .Range("A11", .Range("A" & Rows.Count).End(xlUp))
End With
With Sheet2
    For Each Cll In Rng
        If Cll.Value <> Empty And IsNumeric(Cll.Value) Then
            .Range("N55").Value = Cll.Value
            .PrintPreview
            SoBB = .Range("A53").Value
            If InStrRev(SoBB, "VC", -1, vbBinaryCompare) > 0 Then
                Sheet3.PrintPreview: Sheet4.PrintPreview: GoTo Tiep
            End If
            If InStrRev(SoBB, "ATGT", -1, vbBinaryCompare) > 0 Then
                Sheet5.PrintPreview: GoTo Tiep
            End If
            If InStrRev(SoBB, "BT", -1, vbBinaryCompare) > 0 Then
                Sheet4.PrintPreview
            End If
        End If
Tiep:
    Next
End With
End Sub
Khi nào ưng cái bụng thì thay PrintPreview bằng PrintOut nhoé
 
Bạn tham khảo thử
Mã:
Sub InBB()
    Dim Rng As Range, Cll As Range, SoBB As String
With Sheet1
    Set Rng = .Range("A11", .Range("A" & Rows.Count).End(xlUp))
End With
With Sheet2
    For Each Cll In Rng
        If Cll.Value <> Empty And IsNumeric(Cll.Value) Then
            .Range("N55").Value = Cll.Value
            .PrintPreview
            SoBB = .Range("A53").Value
            If InStrRev(SoBB, "VC", -1, vbBinaryCompare) > 0 Then
                Sheet3.PrintPreview: Sheet4.PrintPreview: GoTo Tiep
            End If
            If InStrRev(SoBB, "ATGT", -1, vbBinaryCompare) > 0 Then
                Sheet5.PrintPreview: GoTo Tiep
            End If
            If InStrRev(SoBB, "BT", -1, vbBinaryCompare) > 0 Then
                Sheet4.PrintPreview
            End If
        End If
Tiep:
    Next
End With
End Sub
Khi nào ưng cái bụng thì thay PrintPreview bằng PrintOut nhoé
em hỏi thêm chút. bây giờ mình muốn chọn số thứ tự in biên bản thì làm thế nào ạ.... ví dụ chỉ in biên bản theo số thựu tự từ 2-5 chẳng hạn ạ
 

File đính kèm

  • 8. BBNT (1).xlsm
    1.3 MB · Đọc: 30
Giúp thêm em về hàm này với ạ... Em có nhiều chuỗi phải nối kiểu này.
Bạn thử cái hàm này xem sao
Mã:
Function UniqueTextJoin(ByVal Table_Array As Range, Optional Delimiter As String) As String
    Dim sArr, Str, N As Long
    Dim Dic As Object, Tmp, Khoa As String
Set Dic = CreateObject("Scripting.Dictionary")
sArr = Table_Array.Value
For Each Str In sArr
    Tmp = Split(Str, Delimiter)
    For N = 0 To UBound(Tmp)
        If Tmp(N) <> Empty Then
            Khoa = Trim(Tmp(N))
            If Not Dic.Exists(Khoa) Then Dic.Add Khoa, ""
        End If
    Next N
Next
If Dic.Count Then UniqueTextJoin = Join(Dic.Keys, Delimiter)
End Function
Mã:
D7=UniqueTextJoin(B5:B9;", ")
 
Bạn thử cái hàm này xem sao
Mã:
Function UniqueTextJoin(ByVal Table_Array As Range, Optional Delimiter As String) As String
    Dim sArr, Str, N As Long
    Dim Dic As Object, Tmp, Khoa As String
Set Dic = CreateObject("Scripting.Dictionary")
sArr = Table_Array.Value
For Each Str In sArr
    Tmp = Split(Str, Delimiter)
    For N = 0 To UBound(Tmp)
        If Tmp(N) <> Empty Then
            Khoa = Trim(Tmp(N))
            If Not Dic.Exists(Khoa) Then Dic.Add Khoa, ""
        End If
    Next N
Next
If Dic.Count Then UniqueTextJoin = Join(Dic.Keys, Delimiter)
End Function
Mã:
D7=UniqueTextJoin(B5:B9;", ")
Bạn thử cái hàm này xem sao
Mã:
Function UniqueTextJoin(ByVal Table_Array As Range, Optional Delimiter As String) As String
    Dim sArr, Str, N As Long
    Dim Dic As Object, Tmp, Khoa As String
Set Dic = CreateObject("Scripting.Dictionary")
sArr = Table_Array.Value
For Each Str In sArr
    Tmp = Split(Str, Delimiter)
    For N = 0 To UBound(Tmp)
        If Tmp(N) <> Empty Then
            Khoa = Trim(Tmp(N))
            If Not Dic.Exists(Khoa) Then Dic.Add Khoa, ""
        End If
    Next N
Next
If Dic.Count Then UniqueTextJoin = Join(Dic.Keys, Delimiter)
End Function
Mã:
D7=UniqueTextJoin(B5:B9;", ")
Em copy vào sao mà nó không chạy ra được kết quả mong muốn ạ
 

File đính kèm

  • gpe2.xlsx
    9 KB · Đọc: 1
Em hỏi thêm bác về cách tính này với ạ
Thêm nhiều thế :p:p:p
Mã:
Function SumDate(ByVal Date_value As Date, _
        ByVal Table_Lookup As Range, ByVal Col_Index As Long) As Long
    Dim sArr(), i As Long, fDate As Date, eDate As Date, Sum_Date As Long
sArr = Table_Lookup.Value
For i = 1 To UBound(sArr)
    If sArr(i, Col_Index) <> Empty Then
        fDate = sArr(i, 1): eDate = sArr(i, 2)
        If Date_value <= eDate Then
            If Date_value >= fDate Then
                Sum_Date = sArr(i, Col_Index) + Sum_Date
            End If
        End If
    End If
Next i
SumDate = Sum_Date
End Function
 

File đính kèm

  • tinh nhân công2.xlsm
    14.9 KB · Đọc: 22
Web KT
Back
Top Bottom