Nếu lỗi lệnh dòng 2 thì thực hiện lệnh dòng 3 (1 người xem)

Liên hệ QC

Người dùng đang xem chủ đề này

hoangexcell

Thành viên tiêu biểu
Tham gia
8/1/08
Bài viết
459
Được thích
132
Donate (Momo)
Donate
Giới tính
Nam
Bữa nay chắc hỏi lần cuối thôi, mai không đụng tới excel nữa. Nên cao nhân nào biết chỉ dùm tình huống sau nhe:


Mã:
Sub a()

dem = Application.Match("N", Range(Cells(Selection.Row, Selection.Column), Cells(Selection.Row, 47)), 0)
dem = 7 (chỉ thực hiện khi lệnh trên báo lỗi không tìm ra N)

Range(Cells(Selection.Row, Selection.Column), Cells(Selection.Row, Selection.Column + dem - 2)).Value = 12

End Sub
 
Bữa nay chắc hỏi lần cuối thôi, mai không đụng tới excel nữa. Nên cao nhân nào biết chỉ dùm tình huống sau nhe:


Mã:
Sub a()

dem = Application.Match("N", Range(Cells(Selection.Row, Selection.Column), Cells(Selection.Row, 47)), 0)
dem = 7 (chỉ thực hiện khi lệnh trên báo lỗi không tìm ra N)

Range(Cells(Selection.Row, Selection.Column), Cells(Selection.Row, Selection.Column + dem - 2)).Value = 12

End Sub
Thì anh sử dụng hàm if vào và khai báo biến dem.nữa .
 
Lần chỉnh sửa cuối:
Bạn thử cái này xem sao?
PHP:
Sub a()
On Error GoTo LoiCT
Dem = Application.Match("N", Range(Cells(Selection.Row, Selection.Column), Cells(Selection.Row, 47)), 0)

Range(Cells(Selection.Row, Selection.Column), Cells(Selection.Row, Selection.Column + Dem - 2)).Value = 12
Err_:                   Exit Sub
LoiCT:
    Dem = 7 'Chi Thuc Hiên Khi Lênh Trên Báo Lôi Không Tìm Ra "N"   '
    Resume Next
End Sub
 
Chỉnh sửa lần cuối bởi điều hành viên:
Web KT

Bài viết mới nhất

Back
Top Bottom