สอบถามผู้รู้ครับ โค้ดลบย้อยขึ้นไป 1 ช่อง
Posted: Sat Nov 23, 2019 1:44 am
Code: Select all
Sub Button_250()
Call LoopRange("250")
End Sub
Sub LoopRange(cell As String)
Dim rngAll As Range
Dim r As Range
Dim i As Integer
With Worksheets("Sheet1")
Set rngAll = .Range("A1:A20")
For i = 1 To 1
For Each r In rngAll.Columns(i).Cells
If r.Value = "" Then
r.Value = cell
Exit Sub
End If
Next r
Next i
End With
End Sub
Sub Button_500()
Call LoopRange1("500")
End Sub
Sub LoopRange1(cell As String)
Dim rngAll As Range
Dim r As Range
Dim i As Integer
With Worksheets("Sheet1")
Set rngAll = .Range("A1:A20")
For i = 1 To 1
For Each r In rngAll.Columns(i).Cells
If r.Value = "" Then
r.Value = cell
Exit Sub
End If
Next r
Next i
End With
End Sub
Sub Button_D()
Range("A1:A20").ClearContents
End Sub
ปล. ถ้าผมทำอะไรผิดขั้นตอนไปต้องขอโทษด้วยนะครับ