jolivanes
Well-known Member
- Joined
- Sep 5, 2004
- Messages
- 2,781
- Office Version
- 2013
- 2007
- Platform
- Windows
If I use the following:
It selects the right range, including some empty cells. In other words, it
selects from D13 to the last cell with a value in it.
However, when I use the following:
It gives the wrong answer. It must be the right answer but not what I am after. It does not
include the amount of cells from the bottom up equal to the amount of empty cells (rows).
I have tried all kind of different approaches found on this forum but I can't get it.
Could someone please tell me where I am going wrong.
Thanks and regards.
John
Code:
Sheets("Sheet1").Range("D13:D" & Cells(Rows.Count, "D").End(xlUp).Row).Select
It selects the right range, including some empty cells. In other words, it
selects from D13 to the last cell with a value in it.
However, when I use the following:
Code:
Dim myRange As Range
Set myRange = Worksheets("Sheet1").Range("D13:D" & Cells(Rows.Count, "D").End(xlUp).Row)
............
here some code
............
Worksheets("Sheet1").Range("D10").Value = _
Application.WorksheetFunction.Sum(myRange)
It gives the wrong answer. It must be the right answer but not what I am after. It does not
include the amount of cells from the bottom up equal to the amount of empty cells (rows).
I have tried all kind of different approaches found on this forum but I can't get it.
Could someone please tell me where I am going wrong.
Thanks and regards.
John