This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Sub Replace_Test01() 'Excel VBA to replace strings. | |
Dim strA As String | |
Dim strB As String | |
strA=" (*" | |
strB="" | |
Rows("1:10").Replace strA, strB | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Replace_Test02() 'Excel VBA for replace with wildcard. | |
Dim strA As String | |
Dim strB As String | |
strA=" (*)" | |
strB="" | |
Rows("1:10").Replace strA, strB | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub Worksheet_SelectionChange(ByVal Target As Range) | |
'Hủy bỏ lệnh to màu cho vùng A1:Z1000 | |
With Range("A1:Z1000").Interior | |
.Pattern = xlNone | |
.TintAndShade = 0 | |
.PatternTintAndShade = 0 | |
End With | |
'Thực hiện tô màu cho ô được chọn | |
With Target.Interior | |
.Pattern = xlSolid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub BCCT_Update() | |
Application.ScreenUpdating = False | |
'Xoa noi dung cu cua bao cao | |
Range("H6:K100").ClearContents | |
'Lenh cap nhat du lieu tu dong | |
'Tao bo loc tu dong | |
Range("A2:F2").AutoFilter | |
'Loc theo cac dieu kien cua bao cao | |
ActiveSheet.Range("$A$2:$F$47").AutoFilter Field:=2, Criteria1:=Sheet1.Cells(4, 9).Value | |
ActiveSheet.Range("$A$2:$F$47").AutoFilter Field:=1, _ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Private Sub Worksheet_Change(ByVal Target As Range) | |
If Not Application.Intersect(Range("I2:I4"), Range(Target.Address)) Is Nothing Then | |
Call BCCT_Update | |
End If | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Tra_loi() | |
Dim SoDong As Long | |
SoDong = Sheet1.Cells(10, 7).Value + 2 | |
Sheet1.Cells(SoDong, 13).Value = Sheet1.Cells(9, 7).Value | |
Sheet1.Cells(SoDong, 14).Value = Sheet1.Cells(9, 8).Value | |
MsgBox "Ban chon dap an là " & Sheet1.Cells(9, 8).Value | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Ket_qua() | |
MsgBox "Ban tra loi dung " & Sheet1.Cells(2, 15).Value & " cau" | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub An_Cot_Vidu01() | |
With Sheet1 | |
.Range("A1").EntireColumn.Hidden = True 'Ẩn cột A | |
.Range("C1").EntireColumn.Hidden = True 'Ẩn cột C | |
End With | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub An_Cot_Vidu02() | |
Dim i As Integer | |
'Tìm cột cuối cùng trong bảng | |
Dim LastColumn as long | |
Lastcolumn = Sheet1.Range("A1").SpecialCells(xlCellTypeLastCell).Column | |
'Ẩn cột từ cột C tới cột cuối cùng | |
For i = 3 To LastColumn | |
Sheet1.Cells(1, i).EntireColumn.Hidden = True | |
Next i | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub An_Cot_Vidu03() 'Ẩn từ dòng 5 tới dòng cuối cùng có chứa dữ liệu | |
Dim i As Integer | |
'Tìm dòng cuối cùng trong bảng | |
Dim LastRow As Long | |
LastRow = Sheet1.Range("A1").SpecialCells(xlCellTypeLastCell).Row | |
'Ẩn hàng | |
Sheet1.Range("A5:A" & LastRow).EntireRow.Hidden = True | |
End Sub |