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 ChonMoFileVBA() | |
Dim TenFile As Long | |
'Mo thuoc tinh File Open | |
With Application.FileDialog(msoFileDialogOpen) | |
.AllowMultiSelect = True | |
.Show | |
' Hien thi duong dan cua file duoc chon | |
For TenFile = 1 To .SelectedItems.Count | |
MsgBox .SelectedItems(TenFile) | |
Next TenFile |
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 AutoMergeCenter() 'lệnh Tự động trộn ô và căn giữa | |
'Updateby2018.10.18 | |
'Thiết lập các biến | |
Dim Rng As Range | |
Dim xRows As Integer | |
Dim WorkRng As Range | |
Dim i As Integer, j As Integer | |
Set WorkRng = Selection 'Vùng được chọn | |
xRows = WorkRng.Rows.Count 'Biến xác định số dòng của vùng được chọn, là giới hạn phạm vi vòng lặp |
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 RoundNum() | |
'Updateby20140128 | |
Dim Rng As Range | |
Dim WorkRng As Range | |
Dim xNum As Integer | |
On Error Resume Next | |
xTitleId = "KutoolsforExcel" | |
Set WorkRng = Application.Selection | |
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8) |
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_Activate() | |
'Xoa noi dung combobox truoc khi nap lai danh sach | |
Me.cbChonSheet.Clear | |
'Đặt tên biến ws đại diện cho đối tượng worksheet | |
Dim ws As Worksheet | |
'Nạp lại danh sách tên Sheet vào Combobox bằng vòng lặp For Each | |
For Each ws In ThisWorkbook.Worksheets | |
Me.cbChonSheet.AddItem ws.Name |
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 Open_Chrome_HEO() 'Mở trang hocexcel.online trên chrome bằng macro | |
Dim Dir As String 'Biến tên đường dẫn | |
Dim fileName As String 'Biến tên chương trình | |
Dir = "C:\Program Files (x86)\Google\Chrome\Application" 'Tên đường dẫn tới chương trình | |
fileName = "chrome.exe" 'Tên chương trình | |
Shell Dir & "\" & fileName & " https://hocexcel.online/" 'Lệnh mở trình duyệt và dẫn tới trang web chỉ định | |
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 Open_Chrome() 'Gọi ra chương trình Chrome từ VBA Excel | |
Dim Dir As String 'Biến tên đường dẫn | |
Dim fileName As String 'Biến tên chương trình | |
Dir = "C:\Program Files (x86)\Google\Chrome\Application" 'Địa chỉ đường dẫn tới chương trình | |
fileName = "chrome.exe" 'Tên file chạy chương trình | |
Shell Dir & "\" & fileName 'Lệnh gọi chương trình Chrome | |
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 Ma_Huyen_GetData() 'Lọc danh sách Quận/Huyện theo giá trị tỉnh/TP được chọn | |
Sheet1.Range("D2:D1000").ClearContents 'Làm mới danh sách | |
'Thiet lap cac bien | |
Dim vl01 As Integer 'Biến vòng lặp mã tỉnh/tp | |
Dim MaTinh As String 'Vị trí ô mã tỉnh/tp được chọn | |
MaTinh = Sheet1.Range("F1").Value | |
Dim lr_Tinh As Long | |
Dim lr_Huyen As Long | |
lr_Tinh = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row 'Dòng cuối của danh sách tỉnh/tp. Đây là giới hạn cho vòng lặp |
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 Export_to_Word() 'Xuất dữ liệu ra file Word | |
'Khai báo các biến | |
Dim wdapp As Object, wddoc As Object | |
Dim strdocname As String | |
On Error Resume Next | |
'Lấy nội dung vùng dữ liệu bằng cách copy | |
Sheet1.Range("D1:D81").Copy | |
'Mở ứng dụng Word từ VBA | |
Set wdapp = GetObject(, "word.Application") | |
If Err.Number = 429 Then |
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 cbSale_Change() | |
Image1.Picture = LoadPicture(cbSale.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
Private Sub UserForm_Initialize() 'Nạp danh sách ảnh vào combobox | |
Application.ScreenUpdating = False | |
Dim fA() | |
Dim i, n As Integer | |
Dim dName As Variant | |
ChDir "D:\03_HEO2018\12_Userform-Get-Picture-by-combobox" 'Địa chỉ đường dẫn nơi chứa ảnh | |
dName = Dir("*.jpg") 'Tên đối tượng được chọn là các ảnh có đuôi .jpg trong thư mục | |
'Nạp các đối tượng có trong thư mục vào trong 1 danh sách | |
Do While dName <> "" | |
n = n + 1 |