Sửa giúp vba lấy số liệu (1 người xem)

Liên hệ QC

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

khitamdao

Thành viên chính thức
Tham gia
30/3/17
Bài viết
69
Được thích
14
Chào các bạn
- Mình có 1 file DGDB.xlsm; file chưa 2 sub là "tenSheet" và "LaySL"
- Và một file SN052019.xls

+ Mình có viết chương trình vba để làm như sau:
- Chay sub tenSheet () để đổi tên sheet (tên sheet theo thời gian bắt đầu và thời gian kết thúc) và mở file SN052019
(trong file của mình sẽ đổi Sheets(SL_1) thành ngay05; Sheets(SL_2) thành ngay06 .... Sheets (SL_7) thành ngay11)

- Chạy sub LaySL () để lấy số liệu ở file SN052019 cho vào tên sheet như nói trên
cụ thể sheets(ngay05) sẽ lấy số liệu từ ngày 06 đến ngày 15
sheets(ngay06) sẽ lấy số liệu từ ngày 07 đến ngày 16
................
sheets(ngay11) sẽ lấy số liệu từ ngày 12 đến ngày 21

code của sub LaySL () khi chạy thì trong sheets(ngay05) đã lấy đúng số liệu của ngày 06 đến ngày 15
nhưng các sheets khác thì số liệu giống hệt sheets(ngay05)
Mong cao nhân nào sửa giup mình vấn đề này: (làm sao để sheets(ngay06) lấy sl từ ngày 07 đến ngày 16 .... cho đén sheets(ngay11) lấy số liệu từ ngày 12 đến ngày 21)


code trong file:
'==============================================================================================
Sub tenSheet()
wb = ThisWorkbook.Name
For i = 1 To 99
For j = 1 To 99
'Neu o la Sheets, thi dat ten sheets SL_1 den SL_7 theo ten trong cot sheets
If Sheets("Setup").Cells(i, j).Value = "sheets" Then
For m = 1 To 7
ten = "SL_" & m
Sheets(ten).Select
Sheets(ten).Name = Sheets("Setup").Cells(i + m, j).Value
Next m
'Mo file synop
'Neu thoi gian cham thuoc cung 1 thang => mo file thang nay
'Neu thoi gian cham thuoc 2 thang khac nhau => mo 2 file: thang nay va thang truoc
ElseIf Sheets("Setup").Cells(i, j).Value = "fileSynop" Then
If Sheets("Setup").Cells(i + 1, j).Value = Sheets("Setup").Cells(i + 2, j).Value Then
synop2 = Sheets("Setup").Cells(i + 1, j).Value
'Mo file thang nay
Workbooks.Open Filename:=ThisWorkbook.Path & "\SLQT\" & synop2
Else
synop1 = Sheets("Setup").Cells(i + 2, j).Value
synop2 = Sheets("Setup").Cells(i + 1, j).Value
'Mo file thang truoc
Workbooks.Open Filename:=ThisWorkbook.Path & "\SLQT\" & synop1
'Mo file thang nay
Workbooks.Open Filename:=ThisWorkbook.Path & "\SLQT\" & synop2
Workbooks(wb).Activate
End If
Else
End If
Next j
Next i
Workbooks(wb).Activate
Sheets("BangDK").Select
End Sub
'==============================================================================================
'==============================================================================================
Sub LaySL()
wb = ThisWorkbook.Name
For i = 1 To 99
For j = 1 To 99
'Neu o la Sheets, thi dat ten sheets SL_1 den SL_7 theo ten trong cot sheets
If Sheets("Setup").Cells(i, j).Value = "sheets" Then
For m = 1 To 7
tSheets = Sheets("Setup").Cells(i + m, j).Value
For n = 1 To 64 '- hang, ap dung cho file synop DKV
For l = 1 To 23 '- cot, ap dung cho file synop DKV
For mtram = 2 To 99
tram = Workbooks(wb).Sheets("Setup").Cells(mtram, 11).Value
If tram <> "" Then
If tram = Workbooks(Sheets("Setup").Cells(i + 1, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(n, l).Value Then
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 1).Value = Workbooks(wb).Sheets("Setup").Cells(mtram, 10).Value
tten = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(n, l - 1).Value
'=================================================================================================
'+ Ngay thu nhat
' - Tmin
Tmin1 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(n, 8).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 2).Value = Tmin1
' - Tmax
Tmax1 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(n, 9).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 7).Value = Tmax1
' - Thoi tiet 1
tTiet1 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(n, 11).Value
If tTiet1 = Workbooks(wb).Sheets("Setup").Cells(2, 13).Value Then
tTiet11 = Workbooks(wb).Sheets("Setup").Cells(3, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 6).Value = tTiet11
Else
tTiet12 = Workbooks(wb).Sheets("Setup").Cells(2, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 6).Value = tTiet12
End If
' - Thoi tiet 2
tTiet2 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(n, 13).Value
If tTiet2 = Workbooks(wb).Sheets("Setup").Cells(2, 13).Value Then
tTiet21 = Workbooks(wb).Sheets("Setup").Cells(3, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 11).Value = tTiet21
Else
tTiet22 = Workbooks(wb).Sheets("Setup").Cells(2, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 11).Value = tTiet22
End If
' - Xu ly do am; lay do am tb cua 2 osb, lam tron den phan nguyen
For k = n + 1 To 64
For f = 1 To 23
If tten = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(k, f).Value Then
u1 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(k, f + 1).Value
u2 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(k, f + 2).Value
u3 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(k, f + 3).Value
u4 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(k, f + 4).Value
tb1 = Round((u1 + u2) / 2, 0)
tb2 = Round((u3 + u4) / 2, 0)
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 5).Value = tb1
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 10).Value = tb2
Else
End If
Next f
Next k
'
' - Huong gio
'
gio1 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(n, 15).Value
gio2 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(n, 16).Value
gio3 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(n, 17).Value
gio4 = Workbooks(Sheets("Setup").Cells(i + 2, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 2, j).Value).Cells(n, 18).Value

h1 = Workbooks(wb).Worksheets("BangDK").Cells(15, 3).Value
If h1 = "01h" Then
gio11 = gio1
Else
gio11 = gio2
End If
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 3).Value = gio11
wbe = Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 3).Address
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 4).Value = "=ExtractNumber(" & wbe & ")"
With Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 4)
.Copy
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End With
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 3).Value = Left(gio11, Len(gio11) - Len(Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 4).Value))

h2 = Workbooks(wb).Worksheets("BangDK").Cells(15, 4).Value
If h2 = "13h" Then
gio12 = gio3
Else
gio12 = gio4
End If
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 8).Value = gio12
wbe = Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 8).Address
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 9).Value = "=ExtractNumber(" & wbe & ")"
With Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 9)
.Copy
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End With
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 8).Value = Left(gio12, Len(gio12) - Len(Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 9).Value))

'==============================================================================================
'+ Ngay thu hai
' - Tmin
Tmin1 = Workbooks(Sheets("Setup").Cells(i + 3, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 3, j).Value).Cells(n, 8).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 12).Value = Tmin1
' - Tmax
Tmax1 = Workbooks(Sheets("Setup").Cells(i + 3, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 3, j).Value).Cells(n, 9).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 13).Value = Tmax1
' - Thoi tiet 1
tTiet1 = Workbooks(Sheets("Setup").Cells(i + 3, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 3, j).Value).Cells(n, 14).Value
If tTiet1 = Workbooks(wb).Sheets("Setup").Cells(2, 13).Value Then
tTiet11 = Workbooks(wb).Sheets("Setup").Cells(3, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 16).Value = tTiet11
Else
tTiet12 = Workbooks(wb).Sheets("Setup").Cells(2, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 16).Value = tTiet12
End If
'
gio1 = Workbooks(Sheets("Setup").Cells(i + 3, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 3, j).Value).Cells(n, 15).Value
gio2 = Workbooks(Sheets("Setup").Cells(i + 3, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 3, j).Value).Cells(n, 16).Value
gio3 = Workbooks(Sheets("Setup").Cells(i + 3, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 3, j).Value).Cells(n, 17).Value
gio4 = Workbooks(Sheets("Setup").Cells(i + 3, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 3, j).Value).Cells(n, 18).Value

h3 = Workbooks(wb).Worksheets("BangDK").Cells(15, 5).Value
If h3 = "01h" Then
gio21 = gio1
ElseIf h3 = "07h" Then
gio21 = gio2
ElseIf h3 = "13h" Then
gio21 = gio3
Else
gio21 = gio4
End If
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 14).Value = gio21
wbe = Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 14).Address
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 15).Value = "=ExtractNumber(" & wbe & ")"
With Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 15)
.Copy
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End With
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 14).Value = Left(gio21, Len(gio21) - Len(Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 15).Value))

'==============================================================================================
'+ Ngay thu ba
' - Tmin
Tmin1 = Workbooks(Sheets("Setup").Cells(i + 4, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 4, j).Value).Cells(n, 8).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 17).Value = Tmin1
' - Tmax
Tmax1 = Workbooks(Sheets("Setup").Cells(i + 4, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 4, j).Value).Cells(n, 9).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 18).Value = Tmax1
' - Thoi tiet 1
tTiet1 = Workbooks(Sheets("Setup").Cells(i + 4, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 4, j).Value).Cells(n, 14).Value
If tTiet1 = Workbooks(wb).Sheets("Setup").Cells(2, 13).Value Then
tTiet11 = Workbooks(wb).Sheets("Setup").Cells(3, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 21).Value = tTiet11
Else
tTiet12 = Workbooks(wb).Sheets("Setup").Cells(2, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 21).Value = tTiet12
End If
'
gio1 = Workbooks(Sheets("Setup").Cells(i + 4, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 4, j).Value).Cells(n, 15).Value
gio2 = Workbooks(Sheets("Setup").Cells(i + 4, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 4, j).Value).Cells(n, 16).Value
gio3 = Workbooks(Sheets("Setup").Cells(i + 4, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 4, j).Value).Cells(n, 17).Value
gio4 = Workbooks(Sheets("Setup").Cells(i + 4, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 4, j).Value).Cells(n, 18).Value

h4 = Workbooks(wb).Worksheets("BangDK").Cells(15, 6).Value
If h4 = "01h" Then
gio31 = gio1
ElseIf h4 = "07h" Then
gio31 = gio2
ElseIf h4 = "13h" Then
gio31 = gio3
Else
gio31 = gio4
End If
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 19).Value = gio31
wbe = Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 19).Address
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 20).Value = "=ExtractNumber(" & wbe & ")"
With Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 20)
.Copy
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End With
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 19).Value = Left(gio31, Len(gio31) - Len(Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 20).Value))

'==============================================================================================
'+ Ngay thu tu
' - Tmin
Tmin1 = Workbooks(Sheets("Setup").Cells(i + 5, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 5, j).Value).Cells(n, 8).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 22).Value = Tmin1
' - Tmax
Tmax1 = Workbooks(Sheets("Setup").Cells(i + 5, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 5, j).Value).Cells(n, 9).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 23).Value = Tmax1
' - Thoi tiet 1
tTiet1 = Workbooks(Sheets("Setup").Cells(i + 5, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 5, j).Value).Cells(n, 14).Value
If tTiet1 = Workbooks(wb).Sheets("Setup").Cells(2, 13).Value Then
tTiet11 = Workbooks(wb).Sheets("Setup").Cells(3, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 24).Value = tTiet11
Else
tTiet12 = Workbooks(wb).Sheets("Setup").Cells(2, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 24).Value = tTiet12
End If
'==============================================================================================
'+ Ngay thu nam
' - Tmin
Tmin1 = Workbooks(Sheets("Setup").Cells(i + 6, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 6, j).Value).Cells(n, 8).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 25).Value = Tmin1
' - Tmax
Tmax1 = Workbooks(Sheets("Setup").Cells(i + 6, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 6, j).Value).Cells(n, 9).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 26).Value = Tmax1
' - Thoi tiet 1
tTiet1 = Workbooks(Sheets("Setup").Cells(i + 6, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 6, j).Value).Cells(n, 14).Value
If tTiet1 = Workbooks(wb).Sheets("Setup").Cells(2, 13).Value Then
tTiet11 = Workbooks(wb).Sheets("Setup").Cells(3, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 27).Value = tTiet11
Else
tTiet12 = Workbooks(wb).Sheets("Setup").Cells(2, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 27).Value = tTiet12
End If
'==============================================================================================
'+ Ngay thu sau
' - Tmin
Tmin1 = Workbooks(Sheets("Setup").Cells(i + 7, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 7, j).Value).Cells(n, 8).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 28).Value = Tmin1
' - Tmax
Tmax1 = Workbooks(Sheets("Setup").Cells(i + 7, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 7, j).Value).Cells(n, 9).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 29).Value = Tmax1
' - Thoi tiet 1
tTiet1 = Workbooks(Sheets("Setup").Cells(i + 7, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 7, j).Value).Cells(n, 14).Value
If tTiet1 = Workbooks(wb).Sheets("Setup").Cells(2, 13).Value Then
tTiet11 = Workbooks(wb).Sheets("Setup").Cells(3, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 30).Value = tTiet11
Else
tTiet12 = Workbooks(wb).Sheets("Setup").Cells(2, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 30).Value = tTiet12
End If
'==============================================================================================
'+ Ngay thu bay
' - Tmin
Tmin1 = Workbooks(Sheets("Setup").Cells(i + 8, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 8, j).Value).Cells(n, 8).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 31).Value = Tmin1
' - Tmax
Tmax1 = Workbooks(Sheets("Setup").Cells(i + 8, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 8, j).Value).Cells(n, 9).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 32).Value = Tmax1
' - Thoi tiet 1
tTiet1 = Workbooks(Sheets("Setup").Cells(i + 8, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 8, j).Value).Cells(n, 14).Value
If tTiet1 = Workbooks(wb).Sheets("Setup").Cells(2, 13).Value Then
tTiet11 = Workbooks(wb).Sheets("Setup").Cells(3, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 33).Value = tTiet11
Else
tTiet12 = Workbooks(wb).Sheets("Setup").Cells(2, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 33).Value = tTiet12
End If
'==============================================================================================
'+ Ngay thu tam
' - Tmin
Tmin1 = Workbooks(Sheets("Setup").Cells(i + 9, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 9, j).Value).Cells(n, 8).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 34).Value = Tmin1
' - Tmax
Tmax1 = Workbooks(Sheets("Setup").Cells(i + 9, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 9, j).Value).Cells(n, 9).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 35).Value = Tmax1
' - Thoi tiet 1
tTiet1 = Workbooks(Sheets("Setup").Cells(i + 9, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 9, j).Value).Cells(n, 14).Value
If tTiet1 = Workbooks(wb).Sheets("Setup").Cells(2, 13).Value Then
tTiet11 = Workbooks(wb).Sheets("Setup").Cells(3, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 36).Value = tTiet11
Else
tTiet12 = Workbooks(wb).Sheets("Setup").Cells(2, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 36).Value = tTiet12
End If
'==============================================================================================
'+ Ngay thu chin
' - Tmin
Tmin1 = Workbooks(Sheets("Setup").Cells(i + 10, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 10, j).Value).Cells(n, 8).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 37).Value = Tmin1
' - Tmax
Tmax1 = Workbooks(Sheets("Setup").Cells(i + 10, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 10, j).Value).Cells(n, 9).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 38).Value = Tmax1
' - Thoi tiet 1
tTiet1 = Workbooks(Sheets("Setup").Cells(i + 10, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 10, j).Value).Cells(n, 14).Value
If tTiet1 = Workbooks(wb).Sheets("Setup").Cells(2, 13).Value Then
tTiet11 = Workbooks(wb).Sheets("Setup").Cells(3, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 39).Value = tTiet11
Else
tTiet12 = Workbooks(wb).Sheets("Setup").Cells(2, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 39).Value = tTiet12
End If
'==============================================================================================
'+ Ngay thu muoi
' - Tmin
Tmin1 = Workbooks(Sheets("Setup").Cells(i + 11, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 11, j).Value).Cells(n, 8).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 40).Value = Tmin1
' - Tmax
Tmax1 = Workbooks(Sheets("Setup").Cells(i + 11, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 11, j).Value).Cells(n, 9).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 41).Value = Tmax1
' - Thoi tiet 1
tTiet1 = Workbooks(Sheets("Setup").Cells(i + 11, j - 1).Value).Worksheets(Sheets("Setup").Cells(i + 11, j).Value).Cells(n, 14).Value
If tTiet1 = Workbooks(wb).Sheets("Setup").Cells(2, 13).Value Then
tTiet11 = Workbooks(wb).Sheets("Setup").Cells(3, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 42).Value = tTiet11
Else
tTiet12 = Workbooks(wb).Sheets("Setup").Cells(2, 12).Value
Workbooks(wb).Worksheets(tSheets).Cells(mtram + 5, 42).Value = tTiet12
End If
'==============================================================================================
Else
End If
Else
End If
Next mtram
Next l
Next n
Next m
Else
End If
Next j
Next i
MsgBox ("Xong")
End Sub
 

File đính kèm

Lần chỉnh sửa cuối:
Mình đã chỉnh sửa lại bài viết, mô tả lại cho đúng vấn đề mình cần giải quyết, mong các bác trợ giúp, chỉnh sửa hộ mình code cho đúng vỡi :)
 
Upvote 0
Mình đã tự xử lý thành công, xin đóng cửa bài viết
 
Upvote 0
Web KT

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

Back
Top Bottom