Last active
February 18, 2024 09:22
-
-
Save touchiep/4c152ae782d5ec74b4356e9bee5e4caf to your computer and use it in GitHub Desktop.
[VBA]Excel]สำหรับใช้เพื่อแก้ไขข้อความในเซลล์ให้เป็นภาษาที่ถูกต้อง เวลาที่เราพิมพ์ผิดภาษา ใช้ใน Excel โดยจะแก้ไขตรงเซลล์ที่เลือกไว้
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function ETConv(iText As String) | |
'For convert miss spelling in keyboard language from English to Thai (Spelling Thai in English Keyboard) | |
'English Keyboard | |
Dim e1 '1st row | |
'Thai Kedmanee Keyboard | |
Dim t1 '1st row | |
Dim eArray As Variant | |
Dim tArray As Variant | |
Dim i | |
e1 = "1 2 3 4 5 6 7 8 9 0 - = ! @ # $ % ^ & * ( ) _ + q w e r t y u i o p [ ] \ Q W E R T Y U I O P { } | a s d f g h j k l ; ' A S D F G H J K L : "" z x c v b n m , . / Z X C V B N M < > ?" | |
t1 = "ๅ / - ภ ถ ุ ึ ค ต จ ข ช + ๑ ๒ ๓ ๔ ู ฿ ๕ ๖ ๗ ๘ ๙ ๆ ไ ำ พ ะ ั ี ร น ย บ ล ฃ ๐ "" ฎ ฑ ธ ํ ๊ ณ ฯ ญ ฐ , ฅ ฟ ห ก ด เ ้ ่ า ส ว ง ฤ ฆ ฏ โ ฌ ็ ๋ ษ ศ ซ . ผ ป แ อ ิ ื ท ม ใ ฝ ( ) ฉ ฮ ฺ ์ ? ฒ ฬ ฦ" | |
eArray = Split(e1, " ") | |
tArray = Split(t1, " ") | |
ETConv = iText | |
For i = LBound(eArray) To UBound(eArray) | |
ETConv = Replace(ETConv, eArray(i), tArray(i)) | |
Next i | |
End Function | |
Function TEConv(iText As String) | |
'For convert miss spelling in keyboard language from Thai to English (Spelling English in Thai Keyboard) | |
'Thai Keyboard | |
Dim e1 '1st row | |
'Thai Kedmanee Keyboard | |
Dim t1 '1st row | |
Dim eArray As Variant | |
Dim tArray As Variant | |
Dim i | |
e1 = "1 2 3 4 5 6 7 8 9 0 - = ! @ # $ % ^ & * ( ) _ + q w e r t y u i o p [ ] \ Q W E R T Y U I O P { } | a s d f g h j k l ; ' A S D F G H J K L : "" z x c v b n m , . / Z X C V B N M < > ?" | |
t1 = "ๅ / - ภ ถ ุ ึ ค ต จ ข ช + ๑ ๒ ๓ ๔ ู ฿ ๕ ๖ ๗ ๘ ๙ ๆ ไ ำ พ ะ ั ี ร น ย บ ล ฃ ๐ "" ฎ ฑ ธ ํ ๊ ณ ฯ ญ ฐ , ฅ ฟ ห ก ด เ ้ ่ า ส ว ง ฤ ฆ ฏ โ ฌ ็ ๋ ษ ศ ซ . ผ ป แ อ ิ ื ท ม ใ ฝ ( ) ฉ ฮ ฺ ์ ? ฒ ฬ ฦ" | |
eArray = Split(e1, " ") | |
tArray = Split(t1, " ") | |
TEConv = iText | |
For i = LBound(tArray) To UBound(tArray) | |
TEConv = Replace(TEConv, tArray(i), eArray(i)) | |
Next i | |
End Function | |
Sub ETConvert() | |
'Correct miss spelling in active cell to right language from English to Thai. | |
Dim inputStr As String | |
Dim cell As Range | |
If TypeOf Selection Is Excel.Range Then | |
For Each cell In Range(Selection.Address(0, 0)) | |
With cell | |
.Value = ETConv(cell.Value) | |
End With | |
Next | |
Else | |
Debug.Print TypeName(Selection) | |
End If | |
End Sub | |
Sub TEConvert() | |
'Correct miss spelling in active cell to right language from Thai to English. | |
Dim inputStr As String | |
Dim cell As Range | |
If TypeOf Selection Is Excel.Range Then | |
For Each cell In Range(Selection.Address(0, 0)) | |
With cell | |
.Value = TEConv(cell.Value) | |
End With | |
Next | |
Else | |
Debug.Print TypeName(Selection) | |
End If | |
End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment