ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Return value from first row (https://www.excelbanter.com/excel-programming/302872-return-value-first-row.html)

kent

Return value from first row
 
Does anybody know how to return the value (maybe in a msgBox) from first row in the column where the curser is placed ? If I use "activecell.End(xlUp).value" then it will not go all the way to the top if there is some blank cell.

Chip Pearson

Return value from first row
 
Kent,

If you really want row 1, use
MsgBox ActiveSheet.Cells(1, ActiveCell.Column).Value

If you want the first cell in the column containing data, use


Dim R As Range
Set R = ActiveSheet.Cells(1, ActiveCell.Column)
If R.Value = "" Then
Set R = R.End(xlDown)
End If
MsgBox R.Value


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Kent" wrote in message
...
Does anybody know how to return the value (maybe in a msgBox)

from first row in the column where the curser is placed ? If I
use "activecell.End(xlUp).value" then it will not go all the way
to the top if there is some blank cell.



Bob Phillips[_6_]

Return value from first row
 
Cells(1,activecell.column).select

for first row

cells(1,activecell.column).end(xldown).select

for first row with data

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Kent" wrote in message
...
Does anybody know how to return the value (maybe in a msgBox) from first

row in the column where the curser is placed ? If I use
"activecell.End(xlUp).value" then it will not go all the way to the top if
there is some blank cell.




All times are GMT +1. The time now is 02:11 PM.

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