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:
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,621
Messages
5,832,735
Members
430,160
Latest member
a_majda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top