EXCEL TOOLS
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
Excel Add-ins ที่พัฒนาโดยคุณสันติพงศ์ ณสุย (MVP Excel 2010-2020) ด้วยภาษา C# เพื่อแก้ไขปัญหาไฟล์ใหญ่ คำนวณนาน ทำงานช้า จัดการข้อมูลต่าง ๆ ที่ทำงานประจำวันได้อย่างสะดวกรวดเร็ว สนใจคลิกไปดูได้ที่นี่ครับ => Excel Tools
[code]
และปิดด้วย [/code]
ตัวอย่างเช่น [code]dim r as range[/code]
เพื่อให้แตกต่างจากข้อความทั่วไป สะดวกในการอ่านและทดสอบ (คลิกเพื่อดูตัวอย่าง)Code: Select all
Sub DoSomething()
Dim rAll As Range
Dim r As Range
With Sheets("List")
Set rAll = .Range("A2", .Range("A" & Rows.Count).End(xlUp))
End With
For Each r In rAll
MyPath = r.Value
MyFile = r.Offset(0, 1).Value
NewName = r.Offset(0, 2).Value
If Dir(MyPath & "\" & MyFile) <> "" Then
Name MyPath & "\" & MyFile As MyPath & "\" & NewName
End If
Next r
End Sub
Code: Select all
Sub DoSomething()
Dim rAll As Range
Dim r As Range
On Error Resume Next
With Sheets("List")
Set rAll = .Range("A2", .Range("A" & Rows.Count).End(xlUp))
End With
For Each r In rAll
MyPath = r.Value
MyFile = r.Offset(0, 1).Value
NewName = r.Offset(0, 2).Value
If Dir(MyPath & "\" & MyFile) <> "" Then
Name MyPath & "\" & MyFile As MyPath & "\" & NewName
End If
Next r
MsgBox "Finish", vbInformation
End Sub