Page 1 of 1

VBA ในการเปลี่ยนฟอรท์

Posted: Wed Jan 13, 2021 8:33 pm
by วังวู ช่ง
เรียนท่านที่รู้ครับ
ผมลองทำ Code นี้ในการเปลี่ยน font ครับ ไม่รู้ว่าผมทำผิดตรงไหนอย่างไร เหมือนว่า Code ไม่ทำงานครับ
ความต้องการคือว่า ใน a1:a150 ถ้าเป็นตัวเลขให้เปลี่ยนเป็นฟอรท์ Arial Narrow ไม่นั้นก็อไม่เปลี่ยนครับ

Code: Select all

Sub ChangeFont()
   Dim r As Range
   For Each r In Range("a1:a150")
        If r = IsNumber Then
            r.Font.Name = "Arial Narrow"
        End If
   Next r
End Sub

Re: VBA ในการเปลี่ยนฟอรท์

Posted: Wed Jan 13, 2021 11:31 pm
by puriwutpokin
ปรับตรงนี้ครับ

Code: Select all

  If IsNumeric(r) Then

Re: VBA ในการเปลี่ยนฟอรท์

Posted: Thu Jan 14, 2021 5:47 am
by วังวู ช่ง
puriwutpokin wrote: Wed Jan 13, 2021 11:31 pm ปรับตรงนี้ครับ

Code: Select all

  If IsNumeric(r) Then
ขอบคุณมากครับ ใช้เลยครับ ได้ตามต้องการเลยครับ :D :D :D :thup: :thup: :thup: :cp: :cp: :cp: