Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I just wanted to find out the number of rows based on the last cell which has data. I have been trying to use the following Dim LastCell As Double LastCell = Cells(Rows.Count, 5).End(xlUp) But get a VBA error. -- Paul Wilson |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
you need .row after your statement you should also use long instead of
double and qualify the range. you can also use the column letter if it makes it easier. Dim LastCell As Long Dim ws As Worksheet Set ws = Worksheets("Sheet1") LastCell = ws.Cells(Rows.Count, "E").End(xlUp).Row -- Gary Excel 2003 "Paul Wilson" wrote in message ... Hi, I just wanted to find out the number of rows based on the last cell which has data. I have been trying to use the following Dim LastCell As Double LastCell = Cells(Rows.Count, 5).End(xlUp) But get a VBA error. -- Paul Wilson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() one other thing i wanted to add but forgot, this line: LastCell = ws.Cells(Rows.Count, 5).End(xlUp) would not have errored if you had a number in the "lastcell" because it was dimmed as double. "lastcell" would have been = to the value of that last cell if you dimmed it as long or variant or some other type that can hold whatever was stored in that cell. -- Gary "Paul Wilson" wrote in message ... Hi, I just wanted to find out the number of rows based on the last cell which has data. I have been trying to use the following Dim LastCell As Double LastCell = Cells(Rows.Count, 5).End(xlUp) But get a VBA error. -- Paul Wilson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Maddening Dilemma - Compare each cell within column a to each cell in column b and find unique matches | Excel Worksheet Functions | |||
Sum Cell Values of one column based on Another Cell Value in a different column | Excel Worksheet Functions | |||
compare cells in column to criteria, then average next column cell | Excel Worksheet Functions | |||
how to select a single column when this column cross a merged cell | Excel Programming | |||
Format cell in column B based on value in the next cell (column c) | Excel Discussion (Misc queries) |