ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using the data in the last cell (https://www.excelbanter.com/excel-programming/395957-using-data-last-cell.html)

amir

Using the data in the last cell
 
I am trying to define a variable with the data in the last cell in a column.
I've been trying to use the following:

Range("A1").Select
Dim DataCheck2 As Date
DataCheck = Range("A" & (Cells(Rows.Count,
ActiveCell.Column).End(xlUp).Offset(-1, 0).Value)).Value

amir

Using the data in the last cell
 
I am trying to define a variable with the data in the last cell in a column.
I've been trying to use the following:

Range("A1").Select
Dim DataCheck2 As Date
DataCheck = Range("A" & (Cells(Rows.Count,
ActiveCell.Column).End(xlUp)Value)).Value

Gary Keramidas

Using the data in the last cell
 
this is one way

Sub test()
Range("A1").Select
Dim DataCheck2 As Date
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row

DataCheck2 = Range("A" & lastrow).Value
Debug.Print DataCheck2
End Sub



Gary


--


Gary


"Amir" wrote in message
...
I am trying to define a variable with the data in the last cell in a column.
I've been trying to use the following:

Range("A1").Select
Dim DataCheck2 As Date
DataCheck = Range("A" & (Cells(Rows.Count,
ActiveCell.Column).End(xlUp)Value)).Value




Dave Peterson

Using the data in the last cell
 
Dim DataCheck2 as Date
with activesheet
datacheck2 = .cells(.rows.count,"A").end(xlup).value
end with

Watch your variables (datacheck vs. datacheck2)



Amir wrote:

I am trying to define a variable with the data in the last cell in a column.
I've been trying to use the following:

Range("A1").Select
Dim DataCheck2 As Date
DataCheck = Range("A" & (Cells(Rows.Count,
ActiveCell.Column).End(xlUp)Value)).Value


--

Dave Peterson


All times are GMT +1. The time now is 12:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com