Kết quả 1 đến 2 của 2

Chủ đề: Điền công thức để tính nhân công trong bảng dự toán

  1. #1
    khanhnguyen12021 Guest

    Điền công thức để tính nhân công trong bảng dự toán

    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

  2. #2
    Ngày tham gia
    Aug 2015
    Bài viết
    0
    Trích dẫn 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
    Vấn đề này nhất thiết phải dùng code?
    Lập công thức cho 1 lần, dùng Autofilter, copy công thức mất 30 giây là xong

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •