Tìm tiêu đè dòng và tiêu đề cột

Liên hệ QC
Tôi tuân thủ nội quy khi đăng bài

vulunktheky

Thành viên thường trực
Tham gia
2/3/18
Bài viết
268
Được thích
84
Giới tính
Nam
Chào mọi người,
Mình có 1 file dữ liệu như này:
Sheet data chứa dữ liệu theo từng vùng không cố định số dòng và số cột.
- Thì vấn đề của mình là khi nhập vào điều kiện của 1 vùng thì sẽ tìm ra tiêu đề của dòng và tiêu đề của cột đó ở vị trí bất kỳ.

- Ví dụ1: Điều kiện để tìm là 1200, thì điều kiện phải nối thêm số 3 vào để được 31200 để dò tìm sang sheet data
và kết quả trả về là tiêu đề dòng: Screw position và tiêu đề cột: Shooting seat 1.
- Ví dụ 2: Điều kiện để tìm là 1387.01, thì điều kiện phải nối thêm số 3 vào để được 31387.01 để dò tìm sang sheet data
và kết quả trả về là tiêu đề dòng: Safety door closed và tiêu đề cột: Position 1

Mình xin cảm ơn mọi người.
 

File đính kèm

  • lookup.xlsb
    49.5 KB · Đọc: 8
Chào mọi người,
Mình có 1 file dữ liệu như này:
Sheet data chứa dữ liệu theo từng vùng không cố định số dòng và số cột.
- Thì vấn đề của mình là khi nhập vào điều kiện của 1 vùng thì sẽ tìm ra tiêu đề của dòng và tiêu đề của cột đó ở vị trí bất kỳ.

- Ví dụ1: Điều kiện để tìm là 1200, thì điều kiện phải nối thêm số 3 vào để được 31200 để dò tìm sang sheet data
và kết quả trả về là tiêu đề dòng: Screw position và tiêu đề cột: Shooting seat 1.
- Ví dụ 2: Điều kiện để tìm là 1387.01, thì điều kiện phải nối thêm số 3 vào để được 31387.01 để dò tìm sang sheet data
và kết quả trả về là tiêu đề dòng: Safety door closed và tiêu đề cột: Position 1

Mình xin cảm ơn mọi người.
Bạn biết viết code VBA không.
 
Upvote 0
Số trong data có trùng nhau bao giờ không?
 
Upvote 0
Nếu chỉ để xem --> Làm cho bạn cái text search, đánh thử vài kí tự vào để tìm...
Hoặc tạo bảng TongHop rồi dùng Vlookup...Cell C2
 

File đính kèm

  • Vlookup.xlsm
    115.4 KB · Đọc: 3
Upvote 0
Nếu chỉ để xem --> Làm cho bạn cái text search, đánh thử vài kí tự vào để tìm...
Hoặc tạo bảng TongHop rồi dùng Vlookup...Cell C2
dữ liệu ở sheet data mình đưa ra là dữ liệu mẫu, nếu mà dữ liệu lên tới 1000 dòng tương ứng khoảng vài trăm bảng thì sẽ như thế nào bạn.
 
Upvote 0
dữ liệu ở sheet data mình đưa ra là dữ liệu mẫu, nếu mà dữ liệu lên tới 1000 dòng tương ứng khoảng vài trăm bảng thì sẽ như thế nào bạn.
Vài trăm bảng thì kiếm phần mềm khác mà làm.
Tầm cỡ này mà quản lý bằng Excel thì công ty hà tiện quá mức.
 
Upvote 0
Mình cho macro này chạy trên file của bạn:
PHP:
Sub TimKiemDuLieu()
 Dim Rng As Range, sRng As Range, Cls As Range
 Dim MyAdd As String
 Const MyColor = 34
 Dim W As Integer
 
 Sheet1.Select
 With Sheets("Data")
    Set Rng = .UsedRange
    For Each Cls In Range([C2], [C2].End(xlDown))
        Set sRng = Rng.Find(Cls.Value, , xlFormulas, xlPart)
        If sRng Is Nothing Then
            Cls.Interior.ColorIndex = 38
        Else
            W = 0
            MyAdd = sRng.Address
            Do
                W = W + 1
                Cls.Interior.ColorIndex = MyColor + W
                Cls.Offset(, 2).Value = sRng.End(xlToLeft).Value
                Cls.Offset(, 3).Value = sRng.End(xlUp).Value
                Set sRng = Rng.FindNext(sRng)
            Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
        End If
    Next Cls
 End With
End Sub
& kết quả không đến nổi tệ:


Screw positionShooting seat 1
1200​
Screw positionShooting seat 1
Actual material quantityShooting seat 1
1204​
Actual material quantityShooting seat 1
Injection timeShooting seat 1
1208​
Injection timeShooting seat 1
Screw speedShooting seat 1
1212​
Screw speedShooting seat 1
Actual injection rateShooting seat 1
1216​
Actual injection rateShooting seat 1
Actual injection pressureShooting seat 1
1220​
Actual injection pressureShooting seat 1
Feeding timeShooting seat 1
1224​
Feeding timeShooting seat 1
Screw positionShooting seat 2
1201​
Screw positionShooting seat 2
Actual material quantityShooting seat 2
1205​
Actual material quantityShooting seat 2
Injection timeShooting seat 2
1209​
Injection timeShooting seat 2
Screw speedShooting seat 2
1213​
Screw speedShooting seat 2
Actual injection rateShooting seat 2
1217​
Actual injection rateShooting seat 2
Actual injection pressureShooting seat 2
1221​
Actual injection pressureShooting seat 2
Feeding timeShooting seat 2
1225​
Feeding timeShooting seat 2
Screw positionShooting seat 3
1202​
Screw positionShooting seat 3
Actual material quantityShooting seat 3
1206​
Actual material quantityShooting seat 3
Injection timeShooting seat 3
1210​
Injection timeShooting seat 3
Screw speedShooting seat 3
1214​
Screw speedShooting seat 3
Actual injection rateShooting seat 3
1218​
Actual injection rateShooting seat 3
Actual injection pressureShooting seat 3
1222​
Actual injection pressureShooting seat 3
Feeding timeShooting seat 3
1226​
Feeding timeShooting seat 3
Screw positionShooting seat 4
1203​
Screw positionShooting seat 4
Actual material quantityShooting seat 4
1207​
Actual material quantityShooting seat 4
Injection timeShooting seat 4
1211​
Injection timeShooting seat 4
Screw speedShooting seat 4
1215​
Screw speedShooting seat 4
Actual injection rateShooting seat 4
1219​
Actual injection rateShooting seat 4
Actual injection pressureShooting seat 4
1223​
Actual injection pressureShooting seat 4
Feeding timeShooting seat 4
1227​
Feeding timeShooting seat 4
Safety door closedPosition 1
1387​
Upper stop of rear plateShooting seat 1
Safety door openedPosition 1
1387.01​
Safety door openedShooting seat 1
 
Upvote 0
Mình cho macro này chạy trên file của bạn:
PHP:
Sub TimKiemDuLieu()
 Dim Rng As Range, sRng As Range, Cls As Range
 Dim MyAdd As String
 Const MyColor = 34
 Dim W As Integer
 
 Sheet1.Select
 With Sheets("Data")
    Set Rng = .UsedRange
    For Each Cls In Range([C2], [C2].End(xlDown))
        Set sRng = Rng.Find(Cls.Value, , xlFormulas, xlPart)
        If sRng Is Nothing Then
            Cls.Interior.ColorIndex = 38
        Else
            W = 0
            MyAdd = sRng.Address
            Do
                W = W + 1
                Cls.Interior.ColorIndex = MyColor + W
                Cls.Offset(, 2).Value = sRng.End(xlToLeft).Value
                Cls.Offset(, 3).Value = sRng.End(xlUp).Value
                Set sRng = Rng.FindNext(sRng)
            Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
        End If
    Next Cls
 End With
End Sub
& kết quả không đến nổi tệ:


Screw positionShooting seat 1
1200​
Screw positionShooting seat 1
Actual material quantityShooting seat 1
1204​
Actual material quantityShooting seat 1
Injection timeShooting seat 1
1208​
Injection timeShooting seat 1
Screw speedShooting seat 1
1212​
Screw speedShooting seat 1
Actual injection rateShooting seat 1
1216​
Actual injection rateShooting seat 1
Actual injection pressureShooting seat 1
1220​
Actual injection pressureShooting seat 1
Feeding timeShooting seat 1
1224​
Feeding timeShooting seat 1
Screw positionShooting seat 2
1201​
Screw positionShooting seat 2
Actual material quantityShooting seat 2
1205​
Actual material quantityShooting seat 2
Injection timeShooting seat 2
1209​
Injection timeShooting seat 2
Screw speedShooting seat 2
1213​
Screw speedShooting seat 2
Actual injection rateShooting seat 2
1217​
Actual injection rateShooting seat 2
Actual injection pressureShooting seat 2
1221​
Actual injection pressureShooting seat 2
Feeding timeShooting seat 2
1225​
Feeding timeShooting seat 2
Screw positionShooting seat 3
1202​
Screw positionShooting seat 3
Actual material quantityShooting seat 3
1206​
Actual material quantityShooting seat 3
Injection timeShooting seat 3
1210​
Injection timeShooting seat 3
Screw speedShooting seat 3
1214​
Screw speedShooting seat 3
Actual injection rateShooting seat 3
1218​
Actual injection rateShooting seat 3
Actual injection pressureShooting seat 3
1222​
Actual injection pressureShooting seat 3
Feeding timeShooting seat 3
1226​
Feeding timeShooting seat 3
Screw positionShooting seat 4
1203​
Screw positionShooting seat 4
Actual material quantityShooting seat 4
1207​
Actual material quantityShooting seat 4
Injection timeShooting seat 4
1211​
Injection timeShooting seat 4
Screw speedShooting seat 4
1215​
Screw speedShooting seat 4
Actual injection rateShooting seat 4
1219​
Actual injection rateShooting seat 4
Actual injection pressureShooting seat 4
1223​
Actual injection pressureShooting seat 4
Feeding timeShooting seat 4
1227​
Feeding timeShooting seat 4
Safety door closedPosition 1
1387​
Upper stop of rear plateShooting seat 1
Safety door openedPosition 1
1387.01​
Safety door openedShooting seat 1
Dạ, em cảm ơn anh.
 
Upvote 0
Web KT
Back
Top Bottom