Hi all,
I have 3 columns in a sheet that contain formulas but i want to replace this with a value from a vba code as my sheet contains more than 10.000 lines. The formulas start at row 2. Row 1 is a header row.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]timePeriod (column A)[/TD]
[TD]timeTable (column B)[/TD]
[TD]timeCount (column C)[/TD]
[/TR]
[TR]
[TD]=VLOOKUP("W"&D2;tblTime!$A:$N;4;FALSE)[/TD]
[TD]=COUNTIF(tblTime!D:D;tblWeekData!A2)[/TD]
[TD]=IF(SUMPRODUCT(($G$1:$G2=G2)*($A$1:$A2=A2)*($D$1:$D2=D2))>1;0;1)[/TD]
[/TR]
</tbody>[/TABLE]
Usualy i would copy down the formula to the last line but i want the entire process automated and replaced by a hard value instead of the formula.
At the moment i have the following code that isn't working:
Any help would be appreciated.
Kind regards,
Hans
I have 3 columns in a sheet that contain formulas but i want to replace this with a value from a vba code as my sheet contains more than 10.000 lines. The formulas start at row 2. Row 1 is a header row.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]timePeriod (column A)[/TD]
[TD]timeTable (column B)[/TD]
[TD]timeCount (column C)[/TD]
[/TR]
[TR]
[TD]=VLOOKUP("W"&D2;tblTime!$A:$N;4;FALSE)[/TD]
[TD]=COUNTIF(tblTime!D:D;tblWeekData!A2)[/TD]
[TD]=IF(SUMPRODUCT(($G$1:$G2=G2)*($A$1:$A2=A2)*($D$1:$D2=D2))>1;0;1)[/TD]
[/TR]
</tbody>[/TABLE]
Usualy i would copy down the formula to the last line but i want the entire process automated and replaced by a hard value instead of the formula.
At the moment i have the following code that isn't working:
Code:
With ThisWorkbook.Sheets("tblWeekData")
lastRow = .Cells(.Rows.Count, "D").End(xlUp).Row
End With
With ThisWorkbook.Sheets("tblWeekData").Range("A2:A" & lastRow)
.Offset(0, 0).Formula = "=VLOOKUP(""W""&D2;tblTime!$A:$N;" & i & ";FALSE)"
.Offset(0, 0).Value = .Value
.Offset(0, 1).Formula = "=IF(SUMPRODUCT(($G$1:$G2=G2)*($A$1:$A2=A2)*($D$1:$D2=D2))>1;0;1)"
.Offset(0, 1).Value = .Value
.Offset(0, 2).Formula = "=COUNTIF(OFFSET(tblTime!A:A;0;" & i - 1 & ";tblWeekData!A2)"
.Offset(0, 2).Value = .Value
End With
Any help would be appreciated.
Kind regards,
Hans