ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VB to capture the current cells row number (https://www.excelbanter.com/excel-programming/449080-excel-vbulletin-capture-current-cells-row-number.html)

Matt[_40_]

Excel VB to capture the current cells row number
 
I have an excel spreadsheet with 40 columns and 200 rows. Part of my code is below. How do I write the line sEndRow = sRange.Row to correctly get number 10, if my curosr is in cell H10?

Thanks in advance,
Matt




Sub Welcome_Note()

Dim sRange As Range
Dim sEndRow As Integer
Dim sFirst_Name As String
Dim sLast_Name As String

sEndRow = sRange.Row
sFirst_Name = ActiveSheet.Range("A" & sEndRow)
sLast_Name = ActiveSheet.Range("B" & sEndRow)
sFull_Name = sFirst_Name & " " & sLast_Name

End Sub

GS[_2_]

Excel VB to capture the current cells row number
 
Dim lCurrentRow As Long 'never Integer
lCurrentRow = ActiveCell.Row

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



isabelle

Excel VB to capture the current cells row number
 
hi,

Set sRange = ActiveCell
sEndRow = sRange.Row

isabelle


Le 2013-07-31 22:17, Matt a écrit :
I have an excel spreadsheet with 40 columns and 200 rows. Part of my code is below.


How do I write the line sEndRow = sRange.Row to correctly get number 10,
if my curosr is in cell H10?

Thanks in advance,
Matt




Sub Welcome_Note()

Dim sRange As Range
Dim sEndRow As Integer
Dim sFirst_Name As String
Dim sLast_Name As String

sEndRow = sRange.Row
sFirst_Name = ActiveSheet.Range("A" & sEndRow)
sLast_Name = ActiveSheet.Range("B" & sEndRow)
sFull_Name = sFirst_Name & " " & sLast_Name

End Sub


GS[_2_]

Excel VB to capture the current cells row number
 
Set sRange = ActiveCell
sEndRow = sRange.Row


Good answer! I just couldn't address the poor variable naming
convention, though!<g

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion



Matt[_40_]

Excel VB to capture the current cells row number
 
Awesome thanks to the both of you!


All times are GMT +1. The time now is 11:56 AM.

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