Lỗi Set FindNext bên trong Do While

Liên hệ QC

LEHOC

Thành viên chính thức
Tham gia
11/1/17
Bài viết
89
Được thích
0
em bị lỗi ở Phương thức Set c1 = .FindNext(c1) trong file dưới đây, anh/chị xem giúp em với ạ.
File em đính kèm bên dưới ạ, các file *.txt là để gán dữ lieu vào file excel (Sub ImportTextFiles()) sau đó mới chạy Sub XuLy() - Sub bị lỗi Set FindNext
Em cảm ơn!
 

File đính kèm

Mình hay làm thế này:
PHP:
'. . . . . .      '  
Rws = Sh.[c4].CurrentRegion.Rows.Count
Set Rng = Sh.[c4].Resize(Rws)
Set sRng = Rng.Find(Cls.Value, , xlFormulas, xlWhole)
If Not sRng Is Nothing Then
     MyAdd = sRng.Address
     Do
         Lg = Lg + sRng.Offset(, 2).Value:       DThu = DThu + sRng.Offset(, 3).Value
         Set sRng = Rng.FindNext(sRng)
      Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
' . . . . . .     '
 
Upvote 0
Mình hay làm thế này:
PHP:
'. . . . . .      ' 
Rws = Sh.[c4].CurrentRegion.Rows.Count
Set Rng = Sh.[c4].Resize(Rws)
Set sRng = Rng.Find(Cls.Value, , xlFormulas, xlWhole)
If Not sRng Is Nothing Then
     MyAdd = sRng.Address
     Do
         Lg = Lg + sRng.Offset(, 2).Value:       DThu = DThu + sRng.Offset(, 3).Value
         Set sRng = Rng.FindNext(sRng)
      Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
' . . . . . .     '
Em cảm ơn bác nhiều ạ!
 
Upvote 0
Web KT

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

Back
Top Bottom