Which row am i?

kapfrank

Board Regular
Joined
Nov 16, 2005
Messages
112
Is it possible that if my active cell is F12.
I can work with number of the row, in this example number 12.

I need that number so i can work in other sheets with this number.
:wink: :rolleyes: :wink:
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Welcome to the Board!

You can use =ROW() to get a row's number.

For any more detailed help, you'd need to popst back with more specific information as to what you're trying to accomplish.

Hope that helps,

Smitty
 

kapfrank

Board Regular
Joined
Nov 16, 2005
Messages
112
I've made a macro but it isn't working.
Could somebody help me.

Dim k As String
Dim l As Variant

Do
k = ""
k = Application.InputBox("Van welke persoon wilt u een overzicht", "overzicht", Type:=2)
Loop While k = ""

Columns("E:E").Select
Selection.Find(What:=k, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate 'with this line i find a name in a colum'

'Now i want to know the row number, for example it is 12'

l = row() 'i think this is wrong, but i don't know what!'

'because i want to use that number in an other sheet'

Range("B" & l).Select
 

Guentjo

Active Member
Joined
Jul 27, 2004
Messages
347

ADVERTISEMENT

try
Code:
l= ActiveCell.row
 

Zack Barresse

MrExcel MVP
Joined
Dec 9, 2003
Messages
10,881
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
  3. Web
Hey, maybe an adaptation such as ...


<font face=Tahoma New><SPAN style="color:#00007F">Sub</SPAN> TestMePlz()
    <SPAN style="color:#00007F">Dim</SPAN> rngFind <SPAN style="color:#00007F">As</SPAN> Range
    <SPAN style="color:#00007F">Dim</SPAN> kStr <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> iRow <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>

    <SPAN style="color:#00007F">Do</SPAN>
        kStr = Application.InputBox("Van welke persoon wilt u een overzicht", "overzicht", Type:=2)
        <SPAN style="color:#00007F">If</SPAN> kStr = "False" <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
    <SPAN style="color:#00007F">Loop</SPAN> <SPAN style="color:#00007F">While</SPAN> kStr = ""

    <SPAN style="color:#00007F">Set</SPAN> rngFind = Columns("E:E").Find(What:=kStr, After:=Range("E1"), _
        LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
        SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
    
    <SPAN style="color:#00007F">If</SPAN> <SPAN style="color:#00007F">Not</SPAN> rngFind <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN>
        iRow = rngFind.Row
        Range("B" & iRow).Select
    <SPAN style="color:#00007F">Else</SPAN>
        MsgBox "Was not found!"
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
    
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>


In VBA, getting the row is a little different. You must have some sort of worksheet object to return the row from. If it's not valid then it won't work. In the code you posted, Activecell.Row would have sufficed for the row number, but you don't need all that selecting and activating going on.

HTH
 

Watch MrExcel Video

Forum statistics

Threads
1,119,264
Messages
5,577,076
Members
412,762
Latest member
sienweiw
Top