ไปยังเนื้อหาหลัก

วิธีพิมพ์ตัวเลือกทั้งหมดในรายการแบบเลื่อนลงใน Excel

คุณเคยพยายามพิมพ์ตัวเลือกทั้งหมดในรายการดรอปดาวน์ในแผ่นงาน Excel หรือไม่? บทความนี้พูดถึงการพิมพ์ตัวเลือกทั้งหมดในรายการแบบเลื่อนลงลงในงานพิมพ์แยกต่างหากใน Excel

พิมพ์ตัวเลือกทั้งหมดในรายการแบบหล่นลงด้วยรหัส VBA


พิมพ์ตัวเลือกทั้งหมดในรายการแบบหล่นลงด้วยรหัส VBA

รหัส VBA ต่อไปนี้สามารถช่วยคุณพิมพ์ตัวเลือกทั้งหมดในรายการแบบหล่นลงในแผ่นงาน กรุณาดำเนินการดังนี้

1 กด อื่น ๆ + F11 คีย์เพื่อเปิด Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง

2 ใน Microsoft Visual Basic สำหรับแอปพลิเคชัน โปรดคลิก สิ่งที่ใส่เข้าไป > โมดูล. จากนั้นคัดลอกรหัส VBA ต่อไปนี้ลงในหน้าต่างโมดูล ดูภาพหน้าจอ:

รหัส VBA: พิมพ์ตัวเลือกทั้งหมดในรายการดรอปดาวน์ที่ระบุลงในงานพิมพ์แยกกัน

Sub Iterate_Through_data_Validation()
    Dim xRg As Range
    Dim xCell As Range
    Dim xRgVList As Range
    Set xRg = Worksheets("Sheet1").Range("B8")
    Set xRgVList = Evaluate(xRg.Validation.Formula1)
    For Each xCell In xRgVList
        xRg = xCell.Value
        ActiveSheet.PrintOut
    Next
End Sub

หมายเหตุ: ในโค้ด Sheet1 คือชื่อเวิร์กชีตซึ่งมีรายการแบบเลื่อนลงที่คุณต้องการพิมพ์ และ B8 คือเซลล์ที่มีรายการดรอปดาวน์ กรุณาแทนที่ด้วยสิ่งที่คุณต้องการ

3 กด F5 กุญแจสำคัญในการเรียกใช้รหัส

ตัวเลือกทั้งหมดในรายการแบบเลื่อนลงที่ระบุในแผ่นงานบางแผ่นจะถูกพิมพ์แยกกัน


พิมพ์หน้าที่ระบุในแผ่นงานปัจจุบันใน Excel ได้อย่างง่ายดาย:

กับ พิมพ์หน้าเฉพาะ ประโยชน์ของ Kutools สำหรับ Excelคุณสามารถพิมพ์หน้าที่ระบุในแผ่นงานปัจจุบัน เช่น พิมพ์ทั้งหมด ได้อย่างง่ายดาย หน้าคี่ทั้งหมด หน้าคู่, พิมพ์เพียง หน้าปัจจุบันรวมถึงพิมพ์ช่วงหน้าแบบกำหนดเองตามภาพด้านล่างที่แสดง
ดาวน์โหลดและทดลองใช้ทันที! (เส้นทางฟรี 30 วัน)


บทความที่เกี่ยวข้อง:

สุดยอดเครื่องมือเพิ่มผลผลิตในสำนักงาน

🤖 Kutools AI ผู้ช่วย: ปฏิวัติการวิเคราะห์ข้อมูลโดยยึดตาม: การดำเนินการที่ชาญฉลาด   |  สร้างรหัส  |  สร้างสูตรที่กำหนดเอง  |  วิเคราะห์ข้อมูลและสร้างแผนภูมิ  |  เรียกใช้ฟังก์ชัน Kutools...
คุณสมบัติยอดนิยม: ค้นหา เน้น หรือระบุรายการที่ซ้ำกัน   |  ลบแถวว่าง   |  รวมคอลัมน์หรือเซลล์โดยไม่สูญเสียข้อมูล   |   รอบโดยไม่มีสูตร ...
การค้นหาขั้นสูง: VLookup หลายเกณฑ์    VLookup หลายค่า  |   VLookup ข้ามหลายแผ่น   |   การค้นหาที่ไม่ชัดเจน ....
รายการแบบเลื่อนลงขั้นสูง: สร้างรายการแบบหล่นลงอย่างรวดเร็ว   |  รายการแบบหล่นลงขึ้นอยู่กับ   |  เลือกหลายรายการแบบหล่นลง ....
ผู้จัดการคอลัมน์: เพิ่มจำนวนคอลัมน์เฉพาะ  |  ย้ายคอลัมน์  |  สลับสถานะการมองเห็นของคอลัมน์ที่ซ่อนอยู่  |  เปรียบเทียบช่วงและคอลัมน์ ...
คุณสมบัติเด่น: กริดโฟกัส   |  มุมมองการออกแบบ   |   บาร์สูตรใหญ่    สมุดงานและตัวจัดการชีต   |  ห้องสมุดทรัพยากร (ข้อความอัตโนมัติ)   |  เลือกวันที่   |  รวมแผ่นงาน   |  เข้ารหัส/ถอดรหัสเซลล์    ส่งอีเมลตามรายการ   |  ซุปเปอร์ฟิลเตอร์   |   ตัวกรองพิเศษ (กรองตัวหนา/ตัวเอียง/ขีดทับ...) ...
ชุดเครื่องมือ 15 อันดับแรก12 ข้อความ เครื่องมือ (เพิ่มข้อความ, ลบอักขระ, ... )   |   50 + แผนภูมิ ประเภท (แผนภูมิ Gantt, ... )   |   40+ ใช้งานได้จริง สูตร (คำนวณอายุตามวันเกิด, ... )   |   19 การแทรก เครื่องมือ (ใส่ QR Code, แทรกรูปภาพจากเส้นทาง, ... )   |   12 การแปลง เครื่องมือ (ตัวเลขเป็นคำ, การแปลงสกุลเงิน, ... )   |   7 ผสานและแยก เครื่องมือ (แถวรวมขั้นสูง, แยกเซลล์, ... )   |   ... และอื่น ๆ

เพิ่มพูนทักษะ Excel ของคุณด้วย Kutools สำหรับ Excel และสัมผัสประสิทธิภาพอย่างที่ไม่เคยมีมาก่อน Kutools สำหรับ Excel เสนอคุณสมบัติขั้นสูงมากกว่า 300 รายการเพื่อเพิ่มประสิทธิภาพและประหยัดเวลา  คลิกที่นี่เพื่อรับคุณสมบัติที่คุณต้องการมากที่สุด...

รายละเอียด


แท็บ Office นำอินเทอร์เฟซแบบแท็บมาที่ Office และทำให้งานของคุณง่ายขึ้นมาก

  • เปิดใช้งานการแก้ไขและอ่านแบบแท็บใน Word, Excel, PowerPoint, ผู้จัดพิมพ์, Access, Visio และโครงการ
  • เปิดและสร้างเอกสารหลายรายการในแท็บใหม่ของหน้าต่างเดียวกันแทนที่จะเป็นในหน้าต่างใหม่
  • เพิ่มประสิทธิภาพการทำงานของคุณ 50% และลดการคลิกเมาส์หลายร้อยครั้งให้คุณทุกวัน!
Comments (15)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I am using the code above which is work great.  Now I need to get it to use the cell reference as the file name when it saves.  How do I do that?
This comment was minimized by the moderator on the site
kalo ingin mencetak sebagian data di drop list, gimana caranya mas ?
terima kasih
This comment was minimized by the moderator on the site
Thanks i used the first option it s amazing but i need to add to it that if there is a blank cell it should not print that option
This comment was minimized by the moderator on the site
Hello MichHave you found the VBA code for print all options in drop down list excluding the empty cell so as you can help is too.
This comment was minimized by the moderator on the site
Hi,The following VBA code helps to print all options in a specific drop-down list excluding the empty items. Hope I can help.<div data-tag="code">Sub Iterate_Through_data_Validation_NULL()
'Updated by Extendoffice 20211231
On Error Resume Next
Dim xRg As Range
Dim xCell As Range
Dim xRgVList As Range
Dim xNum, xF As Integer
xNum = 2
Set xRg = Worksheets("Sheet1").Range("B17")
Set xRgVList = Evaluate(xRg.Validation.Formula1)
xF = 1
For Each xCell In xRgVList
xRg = xCell.Value
If Trim(xCell.Value) = "" Then
Else
'ActiveSheet.PrintPreview
ActiveSheet.PrintOut
End If
Next
End Sub
This comment was minimized by the moderator on the site
Thanks i used the first option it s amazing but i need to add to it that if there is a blank cell it should not print that option
This comment was minimized by the moderator on the site
Hi,
The following VBA code helps to print all options in a specific drop-down list excluding the empty items. Hope I can help.
<div data-tag="code">Sub Iterate_Through_data_Validation_NULL()
'Updated by Extendoffice 20211231
On Error Resume Next
Dim xRg As Range
Dim xCell As Range
Dim xRgVList As Range
Dim xNum, xF As Integer
xNum = 2
Set xRg = Worksheets("Sheet1").Range("B17")
Set xRgVList = Evaluate(xRg.Validation.Formula1)
xF = 1
For Each xCell In xRgVList
xRg = xCell.Value
If Trim(xCell.Value) = "" Then
Else
'ActiveSheet.PrintPreview
ActiveSheet.PrintOut
End If
Next
End Sub
This comment was minimized by the moderator on the site
Hi is there a way to be able to preview first all the possible printouts in my drop-down list before it actually prints?
This comment was minimized by the moderator on the site
Hi Zack,The following VBA code helps to have a print preview before printing. After running the code, the print preview of a drop-down item pops up, you need to manually close the print preview to get the option to print out. <div data-tag="code">Sub Iterate_Through_data_Validation_NULL()
'Updated by Extendoffice 20211231
On Error Resume Next
Dim xRg As Range
Dim xCell As Range
Dim xRgVList As Range
Dim xNum, xF As Integer
xNum = 2
Set xRg = Worksheets("Sheet1").Range("B17")
Set xRgVList = Evaluate(xRg.Validation.Formula1)
xF = 1
For Each xCell In xRgVList
xRg = xCell.Value
If Trim(xCell.Value) = "" Then
Else
ActiveSheet.PrintPreview
ActiveSheet.PrintOut
End If
Next
End Sub
This comment was minimized by the moderator on the site
How can i select a specific droplist, i want to print? , For example if i have 200 names on my droplist and i want to print a specific list, maybe 50 out of 200, How will i do this please?
This comment was minimized by the moderator on the site
Hi,The VBA code below can help you achieve it. Please specify the number of items you want to print in the line "xNum = 10", and the first n options in the drop-down list will be printed out.<div data-tag="code">Sub Iterate_Through_data_Validation_Num1()
'Updated by Extendoffice 20211231
On Error Resume Next
Dim xRg As Range
Dim xCell As Range
Dim xRgVList As Range
Dim xNum, xF As Integer
xNum = 10 'the number of items you want to print
Set xRg = Worksheets("Sheet1").Range("B17")
Set xRgVList = Evaluate(xRg.Validation.Formula1)
xF = 1
For Each xCell In xRgVList
xRg = xCell.Value
'ActiveSheet.PrintPreview '??
ActiveSheet.PrintOut '??
If xF = xNum Then
Exit For
End If
xF = xF + 1
Next
End Sub
This comment was minimized by the moderator on the site
Thanks for the code. But I'm experiencing a minor issue when printing. When I tried to print the sheet with the drop down list. The first print out, prints the first item on the list while the next print out prints a blank data before it prints the second item from the list. What should I do?
This comment was minimized by the moderator on the site
Hi Cloud,
What version of Excel are you using?
The problem can't be reproduced in my case. Sorry for the inconvenience.
This comment was minimized by the moderator on the site
Sorry I totally forgot about this. I'm using Excel 2013.

So it wasn't actually a blank data.

I have this dynamic drop down list in cell R17 which also populates other cells in the worksheet using VLOOKUP Function. What happens during print out is that the odd-positioned items on the list appears on the cell while the even-positioned items seemed not to show up that's why I thought it's printing blank pages.

Thanks!
This comment was minimized by the moderator on the site
Thank you for the post, this has helped me a lot. I was wondering if you had a way to do VBA to print Page 1 based on one drop-down selection and print Page 1 and 2 based on another drop-down selection? Thanks for any help you can provide.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations