เรียน อาจารย์ Snasui
ผมลองเขียน Code แต่ยังติดปัญหาอยู่ครับ
Sheet Input จะเป็นหน้ากรอกข้อมูล , Sheet Forms จะเป็นหน้าแสดงผล
1.ในส่วนของ Procedure อยากให้แยกข้อมูลตามสิ่งที่อยากได้
2.ส่วนของ Special DF, Prothsthesis, Implant และ Other Charges อยากให้แต่ละหัวข้อรวมกันเลย
หมายเหตุ อยากให้แสดงลำดับหัวข้อด้วย (ตามสิ่งที่อยากได้)
ต้องปรับ Code อย่างไรครับ ขอบคุณครับ
Code: Select all
Private Sub CommandButton1_Click()
'Define abbreviations for worksheets
Dim WI As Worksheet
Dim WF As Worksheet
Set WI = Worksheets("Input")
Set WF = Worksheets("Forms")
HeadingRow1 = WF.Range("FormsFirstLine1").Row
CurrentRow1 = HeadingRow1
For Each AmountCell1 In WI.Range("inputProcedure").Cells
If AmountCell1 <> "" Then
WF.Cells(HeadingRow1, 6) = ""
CurrentRow1 = CurrentRow1 + 1
WF.Cells(CurrentRow1, 1) = AmountCell1
End If
Next
For Each AmountCell1 In WI.Range("InputDoctorfree").Cells
If AmountCell1 <> "" Then
WF.Cells(HeadingRow1, 6) = ""
CurrentRow1 = CurrentRow1 + 1
WF.Cells(CurrentRow1, 1) = "Specail DF"
WF.Cells(CurrentRow1, 6) = Application.WorksheetFunction.Sum(AmountCell1.Offset(0, 1))
End If
Next
For Each AmountCell1 In WI.Range("InputProthsthesis").Cells
If AmountCell1 <> "" Then
WF.Cells(HeadingRow1, 6) = ""
CurrentRow1 = CurrentRow1 + 1
WF.Cells(CurrentRow1, 1) = "Prothsthesis"
WF.Cells(CurrentRow1, 6) = Application.WorksheetFunction.Sum(AmountCell1.Value)
End If
Next
For Each AmountCell1 In WI.Range("InputImplant").Cells
If AmountCell1 <> "" Then
WF.Cells(HeadingRow1, 6) = ""
CurrentRow1 = CurrentRow1 + 1
WF.Cells(CurrentRow1, 1) = "Implant"
WF.Cells(CurrentRow1, 6).Formula = Application.WorksheetFunction.Sum(AmountCell1.Value)
End If
Next
For Each AmountCell1 In WI.Range("InputOther").Cells
If AmountCell1 <> "" Then
WF.Cells(HeadingRow1, 6) = ""
CurrentRow1 = CurrentRow1 + 1
WF.Cells(CurrentRow1, 1) = "Other Charges"
WF.Cells(CurrentRow1, 6) = Application.WorksheetFunction.Sum(AmountCell1.Text)
End If
Next
For Each AmountCell1 In WI.Range("InputIncure").Cells
If AmountCell1 <> "" Then
WF.Cells(HeadingRow1, 6) = ""
CurrentRow1 = CurrentRow1 + 1
WF.Cells(CurrentRow1, 1) = AmountCell1.Offset(0, -7)
WF.Cells(CurrentRow1, 6) = AmountCell1.Text
End If
Next
Do While CurrentRow1 < WF.Range("FormsLastLine1").Row
CurrentRow1 = CurrentRow1 + 1
WF.Cells(CurrentRow1, 1) = ""
WF.Cells(CurrentRow1, 5) = ""
WF.Cells(CurrentRow1, 6) = ""
Loop
End Sub
You do not have the required permissions to view the files attached to this post.