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

จะเลือกแถวอื่น ๆ หรือแถวที่ n ใน Excel ได้อย่างไร?

เมื่อเราใช้แผ่นงานบางครั้งเราจำเป็นต้องเลือกแถวอื่น ๆ หรือแถวที่ n ของแผ่นงานสำหรับการจัดรูปแบบการลบหรือการคัดลอก คุณสามารถเลือกได้ด้วยตนเอง แต่ถ้ามีหลายร้อยแถววิธีนี้ก็ไม่ใช่ทางเลือกที่ดี นี่คือเทคนิคบางอย่างที่จะช่วยคุณได้

เลือกแถวอื่น ๆ หรือแถวที่ n ด้วย VBA

เลือกแถวอื่น ๆ หรือแถวที่ n ด้วย Kutools for Excelความคิดที่ดี 3


เลือกแถวอื่น ๆ หรือแถวที่ n ด้วย VBA

ในตัวอย่างนี้ฉันจะเลือกหนึ่งแถวโดยมีสองช่วงเวลา ด้วยรหัส VBA ฉันสามารถทำให้เสร็จได้ดังนี้:

1. เน้นช่วงที่คุณต้องการเลือกแถวอื่น ๆ หรือแถวที่ n

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

Sub EveryOtherRow()
Dim rng As Range
Dim InputRng As Range
Dim OutRng As Range
Dim xInterval As Integer
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
xInterval = Application.InputBox("Enter row interval", xTitleId, Type:=1)
For i = 1 To InputRng.Rows.Count Step xInterval + 1
    Set rng = InputRng.Cells(i, 1)
    If OutRng Is Nothing Then
        Set OutRng = rng
    Else
        Set OutRng = Application.Union(OutRng, rng)
    End If
Next
OutRng.EntireRow.Select
End Sub

3. จากนั้นคลิก doc- คูณ - คำนวณ -3 ปุ่มเพื่อเรียกใช้รหัส และกล่องโต้ตอบจะปรากฏขึ้นเพื่อให้คุณเลือกช่วง ดูภาพหน้าจอ:



4 คลิก OKและในกรณีนี้ฉันป้อน 3 ในกล่องโต้ตอบป๊อปเอาต์อื่นเป็นแถวช่วงเวลา ดูภาพหน้าจอ

5 คลิก OKและทุกแถวที่สามถูกเลือก ดูภาพหน้าจอ:

คุณสามารถเปลี่ยนช่วงเวลาได้ตามต้องการในวินาที KutoolsforExcel โต้ตอบ


เลือกแถวอื่น ๆ หรือแถวที่ n ด้วย Kutools for Excel

ด้วยรหัส VBA คุณสามารถเลือกได้เพียงหนึ่งแถวที่มีช่วงเวลาที่กำหนดหากคุณต้องการเลือกสองสามแถวหรือแถวอื่น ๆ ตามช่วงเวลาที่กำหนด Kutools สำหรับ Excel สามารถช่วยคุณแก้ปัญหานี้ได้อย่างง่ายดายและสะดวก

Kutools สำหรับ Excel, ที่มีมากกว่า 300 ฟังก์ชั่นที่มีประโยชน์ทำให้งานของคุณง่ายขึ้น 

หลังจาก ติดตั้งฟรี Kutools สำหรับ Excel โปรดทำดังนี้:

1 คลิก Kutools > Select > Select Interval Rows & Columns…, ดูภาพหน้าจอ:

doc เลือกทุกแถว 8

2 ใน  Select Interval Rows & Columns กล่องโต้ตอบคลิกdoc-แทนที่ช่วงชื่อ-7 ปุ่มเพื่อเลือกช่วงที่คุณต้องการเลือก Rows or Columns ราคาเริ่มต้นที่ Select ส่วนและระบุหมายเลขที่คุณต้องการในไฟล์ Interval of ช่องป้อนข้อมูลและ Rows ช่องป้อนข้อมูล ดูภาพหน้าจอ:

doc เลือกทุกแถว 9

doc เลือกทุกแถว 10

หมายเหตุ:
1. หากคุณต้องการเลือกแถวอื่น ๆ ทั้งหมดในการเลือกโปรดป้อน 2 ในช่องช่วงเวลาการป้อนข้อมูลและ 1 ในช่อง Rows ช่องป้อนข้อมูล

2. หากคุณต้องการเลือกทั้งแถวที่คุณต้องการคุณสามารถตรวจสอบได้ Select entire rows ตัวเลือก
doc เลือกทุกแถว 11


แรเงาแถวอื่น ๆ หรือแถวที่ n ด้วย Kutools for Excel

หากคุณต้องการแรเงาช่วงในแถวอื่น ๆ เพื่อให้ข้อมูลดูโดดเด่นมากขึ้นตามภาพด้านล่างที่แสดงคุณสามารถนำไปใช้ได้ Kutools สำหรับ Excel's Alternate Row/Column Shading ฟังก์ชั่นเพื่อจัดการงานได้อย่างรวดเร็ว

doc เลือกทุกแถว 12
doc ลูกศรลง
doc เลือกทุกแถว 13

หลังจาก ติดตั้งฟรี Kutools สำหรับ Excel โปรดทำดังนี้:

1. เลือกช่วงของเซลล์ที่คุณต้องการเว้นช่วงเฉดสีคลิก Kutools > Format > Alternate Row/Column Shading.
doc เลือกทุกแถว 14

2 ใน Alternate Row/Column Shading โต้ตอบทำดังนี้:

1) เลือกแถวหรือคอลัมน์ที่คุณต้องการแรเงา

2) เลือก Conditional formatting or การจัดรูปแบบมาตรฐาน ตามที่คุณต้องการ

3) ระบุช่วงการแรเงา;

4) เลือกสีแรเงา
doc เลือกทุกแถว 15

3 คลิก Ok. ตอนนี้ช่วงได้รับการแรเงาในทุกแถวที่ n แล้ว

หากคุณต้องการลบเงาออกให้เลือก ลบการแรเงาแถวสำรองที่มีอยู่ ตัวเลือกใน การแรเงาแถว / คอลัมน์สำรอง โต้ตอบ


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

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

🤖 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 (12)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Help, please. This looks great, BUT when I hit the > Run button it fails with a "Compile error: Sub or Function not defined" and the code stopped at "Set rng = InputRng.Rows.Count Step xInterval +1".
This comment was minimized by the moderator on the site
Also I don't get how "Set" and "Step" could ever work together
This comment was minimized by the moderator on the site
Not sure that I will be able to help, but.. First of, there is a spacing between "C" and "ount" in "Count" when i copied your code string over to a module. Secondly, I can´t find your code anywhere else on this page, please submit the whole thing, if the problem remains.
This comment was minimized by the moderator on the site
Replace OutRng.EntireRow.Select with Intersect(OutRng.EntireRow, InputRng).Select if you want every other row within your selection
This comment was minimized by the moderator on the site
really good, thanks!
This comment was minimized by the moderator on the site
The code has one request. Does it have to select the ENTIRE ROW for each nth row? Can't it just select certain cells (range of cells) within each nth row? I don't need all the information in each row. Just certain cells of each nth row.
This comment was minimized by the moderator on the site
I made the modifications below to select 30 rows Sub EveryOtherRow() Dim rng As Range Dim InputRng As Range Dim OutRng As Range Dim xInterval As Integer xTitleId = "KutoolsforExcel" Set InputRng = Application.Selection Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8) xInterval = Application.InputBox("Enter row interval", xTitleId, Type:=1) For i = 1 To InputRng.Rows.Count Step xInterval + 1 Set rng = InputRng.Cells(i, 1).Resize(, 30) 'Resize to the number of columns to select, 30 in this case If OutRng Is Nothing Then Set OutRng = rng Else Set OutRng = Application.Union(OutRng, rng) End If Next OutRng.Select 'Use OutRng.EntireRow.Select to select the entire row End Sub
This comment was minimized by the moderator on the site
Nice, thanks, this was very helpful ^_^
This comment was minimized by the moderator on the site
fanatastic. thanks a lot.it works perfect.I have more than 7000 data that need to select them with different interval.this trick was like a miracle for me.thaaaaaaaanks.
This comment was minimized by the moderator on the site
I'm trying to use the VBA macro in Excel 2010. It will only select the first nth row, not all of them in the selection. If I run it again, it will go to the next. Any idea what I'm doing wrong? Thanks!
This comment was minimized by the moderator on the site
Just saved my ass with this code thanks! My matlab decided to randomly stop working and so I had to resort to excel which I am not as familiar with as with Matlab. This def. helped. Thanks.
This comment was minimized by the moderator on the site
I need to select multiple rows and a fixed interval and move to the other sheet please answer me as soon as possible 
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations