Mã nguồn PHP:
Option Explicit
Sub Chon_Vung_Du_Lieu_Theo_J()
Dim J As Integer, So As Integer, fNum As Long, lNum As Long '*'
So = InputBox("OK / Enter", "For J = 1 to So", "30")
fNum = InputBox("Só Dàu Là:", "GPE.COM", "1") '*'
lNum = InputBox("Só Cuói Là:", "GPE.COM", "9") '*'
For J = 1 To 96
If J = So Then
Range(Cells(30, J - 4), Cells(30, J - 4)).Select
' So nhan cac gia tri: 6,12,18,24,30,36,42,48,...96 '
' Dieu kien mac dinh o day = 1 va 9 "=IF(OR(R[-28]C=1,R[-28]C=9),R[-28]C,"""")" '
' Cau hoi: lieu co cach nao nhap dieu kien tu ngoai vao duoc khong? '
ActiveCell.FormulaR1C1 = "=IF(OR(R[-28]C=" & fNum & "1,R[-28]C=" & lNum & "),R[-28]C,"""")" '*'
Range(Cells(30, J - 4), Cells(30, J - 4)).Select
Selection.AutoFill Destination:=Range(Cells(30, J - 4), Cells(30, J)), Type:=xlFillDefault
Range(Cells(30, J - 4), Cells(30, J)).Select
Selection.AutoFill Destination:=Range(Cells(30, J - 4), Cells(56, J)), Type:=xlFillDefault
Range(Cells(30, J - 4), Cells(56, J)).Select
End If
Next J
End Sub