-
11-17-2011, 07:22 AM #1Junior Member
- Ngày tham gia
- Aug 2015
- Bài viết
- 0
Tạo một danh sách thả xuống trong cell bất kỳ
Nếu bạn muốn tạo 1 List (danh sách bất kỳ) để chọn nhập vào 1 cell. Giả sử bạn có 1 sheet nào đó đã chứa sẳn dữ liệu và muốn tạo 1 danh sách bất kỳ để chọn và nhập dữ liệu vào ô cần nhập, thực hiện như sau:
Click chuột phải vào tên bảng tính cần tạo List, chọn ViewCode cửa sổ Code mở ra và bạn gõ nhập đoạn Code sau vào:
Option Explicit
Dim strRange As String
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Dim cBar As CommandBarPopup
If Target.Row = 1 Then End
If Target.Cells.Count > 1 Then Exit Sub
strRange = Target.EntireColumn.Cells(1, 1).Address & _
":" & Target.Offset(-1, 0).Address
‘Sử dụng validation để chọn phạm vi và thêm vào danh sách
With Target.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=" & strRange
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = False
.ShowError = False
End With
On Error Resume Next
If Not Cancel Then _
Application.CommandBars("Cell").ShowPopup x:=Target.Offset(0, 3).Left
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If strRange <> vbNullString Then Range(strRange).EntireColumn.Validation.Delete
strRange = vbNullString
End Sub
Để lựa chọn danh sách, bạn click phải chuột vào ô bất kỳ và click vào mũi tên sổ xuống để chọn (hoặc nhấn tổ hợp phím Alt + phím↓) bây giờ bạn có thể lựa chọn bất kỳ 1 danh sách để nhập.
Chúc các bạn thực hiện thành công.
---------- Post added 17-11-2011 at 12:22 ---------- Previous post was 16-11-2011 at 11:56 ----------
Các bạn có thể tải File để xem theo Link sau:
Tao Form va List.xls - File Shared from Box - Free Online File StorageView more random threads:
- Hàm đọc số ra chữ
- Tạo mã phiếu thu( hay chi,nhập,. . . .) có dạng MMDDYYxxx
- Tổng hợp sheet của nhiều file excel
- ExTools Excel add-in - Công cụ hỗ trợ Microsoft Excel
- Tạo nút lệnh vừa khít với ô trong Excel
- Kiểm tra giá trị trong ô
- CÁCH TẠO 1FORM ĐỂ NHẬP
- Tạo một danh sách thả xuống trong cell bất kỳ
- Rút ngắn công đoạn Lọc này như thế nào?
- Chuyển kết quả bấm thẻ sang bảng chấm công
Dự án căn hộ cao cấp Eaton Park được phát triển bởi Gamuda Land độc đáo bền vững tầm nhìn rộng bài trí hài hòa. Eaton Park độc đáo bền vững giá ưu đãi phú hợp văn hóa. Dự án khẳng định thương hiệu,...
Eaton Park tiện ích hạng sang vị trí đẹp