---
title: Text.RemoveRange – ลบข้อความจากช่วงที่ระบุ
url: https://www.thepexcel.com/functions/power-query/text-functions/text-removerange/
type: function-explainer
program: Power Query
syntax: "Text.RemoveRange(text as nullable text, offset as number, optional count as nullable number) as nullable text"
date: 2025-12-04
updated: 2025-12-17
scores:
  popularity: 4
  difficulty: 3
  usefulness: 4
---

# Text.RemoveRange – ลบข้อความจากช่วงที่ระบุ

> ลบข้อความจากช่วงที่ระบุ

## คำอธิบาย

Text.RemoveRange ใช้สำหรับลบอักขระจำนวนที่ระบุตั้งแต่ตำแหน่งที่กำหนด ค่าเริ่มต้นจะลบ 1 อักขระหากไม่ระบุจำนวน

## Syntax

```excel
Text.RemoveRange(text as nullable text, offset as number, optional count as nullable number) as nullable text
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| text | Yes | nullable text |  | ข้อความต้นฉบับที่ต้องลบ |
| offset | Yes | number |  | ตำแหน่งเริ่มต้นของการลบ (zero-based) |
| count | No | nullable number | 1 | จำนวนอักขระที่ต้องการลบ |

## เคสการใช้งาน

### ลบนามสกุลไฟล์จากชื่อไฟล์

ลบนามสกุลไฟล์จากชื่อไฟล์

### ลบส่วนที่ไม่ต้องการจากข้อมูล

ลบส่วนที่ไม่ต้องการจากข้อมูล

### ทำความสะอาดข้อความจากอักขระพิเศษ

ทำความสะอาดข้อความจากอักขระพิเศษ

## ตัวอย่าง

### 1. ลบตัวเดียว

```excel
Text.RemoveRange("ABEFC", 2)
```

**ผลลัพธ์:** `ABFC`

ลบตัวที่ 3 (index 2) ซึ่งคือ 'E'

### 2. ลบหลายตัว

```excel
Text.RemoveRange("ABEFC", 2, 2)
```

**ผลลัพธ์:** `ABC`

ลบ 2 ตัวจากตำแหน่ง 2 ('EF')

### 3. ลบนามสกุล

```excel
Text.RemoveRange("document.pdf", 8)
```

**ผลลัพธ์:** `document`

ลบ 4 ตัว (. p d f) เหลือแค่ชื่อไฟล์

## ฟังก์ชันที่เกี่ยวข้อง

- [Text.Remove – ลบอักขระที่ไม่ต้องการ](https://www.thepexcel.com/functions/power-query/text-functions/text-remove/)
- [Text.Replace – แทนที่ข้อความใน Power Query](https://www.thepexcel.com/functions/power-query/text-functions/text-replace/)
- [Text.ReplaceRange – แทนที่ข้อความในช่วงที่ระบุ](https://www.thepexcel.com/functions/power-query/text-functions/text-replacerange/)

## แหล่งข้อมูลเพิ่มเติม

- [Microsoft Learn: Text.RemoveRange](https://learn.microsoft.com/en-us/powerquery-m/text-removerange) _(Official Documentation)_

---

_Source: [https://www.thepexcel.com/functions/power-query/text-functions/text-removerange/](https://www.thepexcel.com/functions/power-query/text-functions/text-removerange/)_
