Private Sub CommandButton2_Click()
Dim i As Long, j As Long, h As Long, Ctrl As Control
[COLOR=#008000][B]' Làm trên mảng rồi gán xuống sheet (cách này nhanh hơn):[/B][/COLOR]
Dim Arr()
ReDim Arr(1 To 8, 1 To 4)
j = 0: h = 1
For i = 1 To 32
Arr(h, i - j) = Controls("TextBox" & i).Value
Select Case i
Case 4, 8, 12, 16, 20, 24, 28, 32
j = j + 4
h = h + 1
End Select
Next
Sheet1.Range("J65536").End(xlUp).Offset(1).Resize(8, 4).Value = Arr
[COLOR=#008000][B]' Làm trực tiếp trên sheet:[/B][/COLOR]
[COLOR=#008000]' With Sheet1.Range("J65536").End(xlUp).Offset(1)
' j = 1
' For i = 1 To 32
' .Offset(h, i - j).Value = Controls("TextBox" & i).Value
' Select Case i
' Case 4, 8, 12, 16, 20, 24, 28, 32
' j = j + 4
' h = h + 1
' End Select
' Next
' End With[/COLOR]
For Each Ctrl In Controls
If TypeName(Ctrl) = "TextBox" Then Ctrl.Text = ""
Next
CommandButton2.Enabled = False
End Sub