tpkelley_no
Board Regular
- Joined
- Oct 14, 2011
- Messages
- 188
- Office Version
- 2010
- Platform
- Windows
I am trying to do an =sumif VBA code. the formula needs to go in the cell that is three cells below the last text cell in column “C”. Here is the formula in excel. =SUMIF(B6:B237,"LAB",K6:K237). The variables will be in column “B” and “K” with the number of rows. I came up with this VBA code but it does not word. Thanks for the help.
Code:
Dim TLCP As Range, BLOOKUP As Range, KLOOKUP As Range
Set TLCP = Range("C6").End(xlDown).Offset(8, 0)
Set BLOOKUP = Range("B6").End(xlDown).Row.Count
Set KLOOKUP = Range("K6").End(xlDown).Row.Count
Cells(TLCP).Formula = "=SUMIF(" & Range("B6:B" & BLOOKUP).Address & ",""LAB""," _
& Range("K6:K" & KLOOKUP).Address & ")"