Thep Excel

Text.ReplaceRange – แทนที่ข้อความในช่วงที่ระบุ

แทนที่ข้อความในช่วงที่ระบุ

Text.ReplaceRange ใช้สำหรับแทนที่อักขระในช่วงที่กำหนดด้วยข้อความใหม่ สามารถใช้ลบหรือแทรกข้อความ

=Text.ReplaceRange(text as nullable text, offset as number, count as number, newText as text) as nullable text

By ThepExcel AI Agent
4 December 2025

Syntax & Arguments

=Text.ReplaceRange(text as nullable text, offset as number, count as number, newText as text) as nullable text

Argument Type Required Default Description
text nullable text Yes ข้อความต้นฉบับ
offset number Yes ตำแหน่งเริ่มต้นของการแทนที่
count number Yes จำนวนอักขระที่ต้องการแทนที่
newText text Yes ข้อความใหม่ที่ต้องแทรก

How it works

แก้ไขส่วนของข้อความที่กำหนด

แก้ไขส่วนของข้อความที่กำหนด

แทนที่อักขระในตำแหน่งที่ระบุ

แทนที่อักขระในตำแหน่งที่ระบุ

ปรับปรุงข้อความตามรูปแบบ

ปรับปรุงข้อความตามรูปแบบ

Examples

แทนที่ HELLO ด้วย HI

แทนที่ 5 ตัวแรก 'HELLO' ด้วย 'HI'
Power Query Formula:

=Text.ReplaceRange("HELLO WORLD", 0, 5, "HI")

Result:

HI WORLD

แทนที่ WORLD ด้วย UNIVERSE

แทนที่ 'WORLD' (5 ตัว) ด้วย 'UNIVERSE'
Power Query Formula:

=Text.ReplaceRange("HELLO WORLD", 6, 5, "UNIVERSE")

Result:

HELLO UNIVERSE

แทรกโดยไม่ลบ

แทรก 'XX' ที่ตำแหน่ง 2 โดยไม่ลบตัวใด
Power Query Formula:

=Text.ReplaceRange("ABCD", 2, 0, "XX")

Result:

ABXXCD

Resources & Related

Additional Notes

Text.ReplaceRange ใช้สำหรับแทนที่อักขระในช่วงที่กำหนดด้วยข้อความใหม่ สามารถใช้ลบหรือแทรกข้อความ

Leave a Reply

Your email address will not be published. Required fields are marked *