Using the data in the last cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
Dim DataCheck2 as Date
with activesheet
datacheck2 = .cells(.rows.count,"A").end(xlup).value
end with

Watch your variables (datacheck vs. datacheck2)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top