บทความนี้ร่วมเขียนโดยเหล่าบรรณาธิการและนักวิจัยที่ผ่านการฝึกฝนมาเพื่อความถูกต้องและครอบคลุมของเนื้อหา
ทีมผู้จัดการด้านเนื้อหาของวิกิฮาว จะตรวจตราผลงานจากทีมงานด้านเนื้อหาของเราเพื่อความมั่นใจว่าบทความทุกชิ้นได้มาตรฐานตามที่เราตั้งไว้
บทความนี้ถูกเข้าชม 91,675 ครั้ง
ต้องการแทรกรูปภาพหรือโลโก้ในชีต Excel เพื่อเพิ่มความดึงดูดสายตาใช่หรือไม่? แม้ว่าจะไม่มีวิธีตั้งค่าให้รูปภาพขยายหรือย่อตามขนาดเซลล์ได้โดยอัตโนมัติ แต่คุณก็สามารถปรับขนาดรูปภาพให้พอดีกับเซลล์ได้ง่ายๆ เพียงไม่กี่คลิก ในบทความนี้เราจะมาเรียนรู้วิธีการแทรกรูปภาพใน Excel พร้อมปรับขนาดให้พอดีกับเซลล์กัน
ขั้นตอน
- เปิดไฟล์งานบน Microsoft Excel. คุณสามารถเปิดไฟล์งานบน Microsoft Excel ได้โดยคลิก File > Open (ไฟล์ > เปิด) หรือคลิกขวาที่ไฟล์งานและเลือก Open with > Excel (เปิดด้วย > Excel)
- แทรกรูปภาพ. คุณสามารถแทรกรูปภาพได้โดยคลิก Insert > Pictures > Selecting your picture > Insert (แทรก > รูปภาพ > เลือกรูปภาพ > แทรก)
- ปรับขนาดรูปภาพ. เมื่อแทรกรูปภาพที่ต้องการแล้ว แท็บ Format (รูปแบบ) จะปรากฏขึ้นภายใต้ Picture Tools (เครื่องมือรูปภาพ) คุณจะพบการตั้งค่าในกลุ่ม Size (ขนาด)
- กรอกค่าที่คุณต้องการลงในกล่อง Height (ความสูง) และ Width (ความกว้าง) เพื่อปรับขนาดรูปภาพ หรือจะปรับขนาดรูปภาพโดยใช้วิธีลากจุดปรับขนาดจากมุมใดมุมหนึ่งของรูปภาพก็ได้เช่นกัน
- ล็อกรูปภาพลงในเซลล์. ตามค่าเริ่มต้น รูปภาพที่คุณแทรกจะลอยอยู่เหนือเซลล์และขนาดรูปภาพจะไม่เปลี่ยนแปลงไปตามขนาดเซลล์ ซึ่งคุณสามารถแก้ไขปัญหานี้ได้ด้วยการล็อกรูปภาพลงในเซลล์เสียก่อน
- คลิกขวาที่รูปภาพและคลิก Format Picture (จัดรูปแบบรูปภาพ) จากนั้นคลิกแท็บ Size & Properties (ไอคอนรูปกล่องสี่เหลี่ยมสีเขียวมีลูกศรชี้สี่ทิศทาง) และเลือก Move and size with cells
- คุณสามารถใช้โค้ด VBA ได้เช่นกัน เริ่มจากแทรกรูปภาพที่ต้องการและกดปุ่ม Alt + F11 เพื่อเปิดหน้าต่าง VBA ขึ้นมา จากนั้นคลิก Insert > Module และวางโค้ดด้านล่างนี้ลงไป:
- กดปุ่ม F5 เพื่อเริ่มรันโค้ด ทำซ้ำขั้นตอนเดิมจนกระทั่งรูปภาพทั้งหมดในชีตมีขนาดพอดีกับขนาดเซลล์
Public Sub FitPic()On Error GoTo NOT_SHAPEDim PicWtoHRatio As SingleDim CellWtoHRatio As SingleWith SelectionPicWtoHRatio = .Width / .HeightEnd WithWith Selection.TopLeftCellCellWtoHRatio = .Width / .RowHeightEnd WithSelect Case PicWtoHRatio / CellWtoHRatioCase Is > 1With Selection.Width = .TopLeftCell.Width.Height = .Width / PicWtoHRatioEnd WithCase ElseWith Selection.Height = .TopLeftCell.RowHeight.Width = .Height * PicWtoHRatioEnd WithEnd SelectWith Selection.Top = .TopLeftCell.Top.Left = .TopLeftCell.LeftEnd WithExit SubNOT_SHAPE:MsgBox "Select a picture before running this macro."End Sub
โฆษณา
เกี่ยวกับวิกิฮาวนี้
บทความนี้เป็นประโยชน์กับคุณไหม
⚠️ Disclaimer:
Content from Wiki How ไท language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.
- - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
- - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
- - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
- - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.