
Gửi bởi
vietquang_205
Sử dụng VBA điền công thức để tính nhân công trong bảng chiết tính của dự toán:
Code VBA
Sub DienCongThucNC()
' Keyboard Shortcut: Ctrl+Shift+D
Dim lSoDong As Long
Dim rCell As Range
Sheets("Chiet tinh").Select
'Tinh so Dong Chi tiet
lSoDong = Range("B65000").End(xlUp).Row - 4
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Range("E5").Resize(lSoDong, 1).Select
For Each rCell In Selection
With rCell
If .FormulaR1C1 = "c«ng" Then
.Offset(, 2).FormulaR1C1 = "=VLOOKUP(RC[-5],'Nhan cong'!R4C1:R55C7,7,0)"
End If
End With
Next
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
Range("E5").Select
End Sub
Sub tinhnhancong()
'
' tinhnhancong Macro
' Bài h?c link don giá nhân công
'
' Keyboard Shortcut: Ctrl+q
'
Range("G7").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-5],'Nhan cong'!R[15]C[-6]:R[216]C,7,0)"
Range("G7").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC2,'Nhan cong'!R22C1:R223C7,7,0)"
Range("G7").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G7").Select
End Sub
Các bạn có thể tham khảo thêm : http://www.giaiphapexcel.com/forum/a...p/t-93684.html