รบกวนอาจารย์ช่วยแนะนำด้วยครับ
Posted: Sat Mar 05, 2016 10:30 pm
ผมต้องการสร้าง เงื่อนไข ในการสั่งพิมพ์ดังนี้
1 ให้ตรวจสอบว่า ช่อง b1 มีค่าเป็นค่าอะไร แล้วสั่งพิมพ์ตามงานนั้น
เช่น ค่าเป็น 1 ก็ให้พิมพ์ ชีท 2 และ 4
ค่าเป็น 2 ก็ให้พิพม์ ชีท 1 และ 5
และก่อนจะพิมพ์ชีท 4 หรือ 5 ให้ตรวจสอบว่ายอดเงินใน b2 เกิน 5000 หากไม่เกินให้ยกเลิกการสั่งพิมพ์ ชีท 4 หรือ 5
Sub print()
If b1 = 1 Then
Sheets("sheet2").setect
ActiveWindow.SelectedSheets.PrintOut From:=1 To:=4, Copies:=1, Collate_
:=True, IgnorePrintAreas:=False
Sheets("sheet4").setect
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True, IgnorePrintAreas:=False
Else
If b1 = 2 Then
Sheets("sheet1").setect
ActiveWindow.SelectedSheets.PrintOut From:=1 To:=4, Copies:=1, Collate_
:=True, IgnorePrintAreas:=False
Sheets("sheet5").setect
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True, IgnorePrintAreas:=False
Else
End if
End Sub
ขอคำแนะนำด้วยครับใหม่มากทดลองอยู่หลายครั้งก็ทำไม่ได้ครับไม่รู้ว่าต้องใช้สูตรยังไงครับ
1 ให้ตรวจสอบว่า ช่อง b1 มีค่าเป็นค่าอะไร แล้วสั่งพิมพ์ตามงานนั้น
เช่น ค่าเป็น 1 ก็ให้พิมพ์ ชีท 2 และ 4
ค่าเป็น 2 ก็ให้พิพม์ ชีท 1 และ 5
และก่อนจะพิมพ์ชีท 4 หรือ 5 ให้ตรวจสอบว่ายอดเงินใน b2 เกิน 5000 หากไม่เกินให้ยกเลิกการสั่งพิมพ์ ชีท 4 หรือ 5
Sub print()
If b1 = 1 Then
Sheets("sheet2").setect
ActiveWindow.SelectedSheets.PrintOut From:=1 To:=4, Copies:=1, Collate_
:=True, IgnorePrintAreas:=False
Sheets("sheet4").setect
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True, IgnorePrintAreas:=False
Else
If b1 = 2 Then
Sheets("sheet1").setect
ActiveWindow.SelectedSheets.PrintOut From:=1 To:=4, Copies:=1, Collate_
:=True, IgnorePrintAreas:=False
Sheets("sheet5").setect
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True, IgnorePrintAreas:=False
Else
End if
End Sub
ขอคำแนะนำด้วยครับใหม่มากทดลองอยู่หลายครั้งก็ทำไม่ได้ครับไม่รู้ว่าต้องใช้สูตรยังไงครับ