Godders199
Active Member
- Joined
- Mar 2, 2017
- Messages
- 313
- Office Version
- 2013
Hello, i have written the following code, which works fine for one row, i am trying to change it to go to the last row, with the criteria changing from A2 to a3. a4 etc,
Range("f2") = WorksheetFunction.CountIfs(ThisWorkbook.Sheets("Adviser data").Range("A:A"), ThisWorkbook.Sheets("advisers").Range("a2"), ThisWorkbook.Sheets("Adviser data").Range("d:d"), ">=" & Daterng, ThisWorkbook.Sheets("Adviser data").Range("d:d"), "<=" & Daterng1)
heres what i have done to try and get to last row
With Sheets("Advisers")
Dim rowlast As Long
rowlast = .Range("a" & Rows.Count).End(xlUp).Row
With .Range("f2& K & rowlast") = WorksheetFunction.CountIfs(ThisWorkbook.Sheets("Adviser data").Range("A:A"), ThisWorkbook.Sheets("advisers").Range("a2"), ThisWorkbook.Sheets("Adviser data").Range("d:d"), ">=" & Daterng, ThisWorkbook.Sheets("Adviser data").Range("d:d"), "<=" & Daterng1)
End With
End With
Can anyone say where i am gong wrong please
Range("f2") = WorksheetFunction.CountIfs(ThisWorkbook.Sheets("Adviser data").Range("A:A"), ThisWorkbook.Sheets("advisers").Range("a2"), ThisWorkbook.Sheets("Adviser data").Range("d:d"), ">=" & Daterng, ThisWorkbook.Sheets("Adviser data").Range("d:d"), "<=" & Daterng1)
heres what i have done to try and get to last row
With Sheets("Advisers")
Dim rowlast As Long
rowlast = .Range("a" & Rows.Count).End(xlUp).Row
With .Range("f2& K & rowlast") = WorksheetFunction.CountIfs(ThisWorkbook.Sheets("Adviser data").Range("A:A"), ThisWorkbook.Sheets("advisers").Range("a2"), ThisWorkbook.Sheets("Adviser data").Range("d:d"), ">=" & Daterng, ThisWorkbook.Sheets("Adviser data").Range("d:d"), "<=" & Daterng1)
End With
End With
Can anyone say where i am gong wrong please