Extract the current row number when the whole row is selected

Briguy2k

New Member
Joined
Jun 25, 2009
Messages
2
I know I'm going to smack my forehead when someone points out how easy it is, but essentially, I'm looking for the opposite of this:

Code:
ActiveCell.Row
Here, when a cell is selected, I use this to get the number of the row that it is in. As you can see below, this code searches for a particular field, then deletes that whole row and adds 2 blank rows in it's place. I end up with a row selected and want to get that row number, go to cell(currentrownumber, "F") and do a autosum. But I can't find the specific function to do this. Any help please? VERY much appreciated.

Code:
    Dim rngFind As Range
    Dim currentrow As Integer
    Dim currentcol As Integer
    currentrow = ActiveCell.Row
    currentcol = ActiveCell.Column
    With Range(Selection, Selection.End(xlDown))
        Do
            Set rngFind = .Find(What:="#Item Number", After:=.Cells(1, 1), LookIn:=xlFormulas, _
                                LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                                MatchCase:=False, SearchFormat:=False)

                If rngFind Is Nothing Then Exit Do
               
            rngFind.EntireRow.Select
            Selection.Delete Shift:=x1up
            Selection.Insert Shift:=xlDown
            Selection.Insert Shift:=xlDown
'           MAGIC CODE
'           Cells(currentrow, "F").Select
'           Application.SendKeys ("%=~")

            
        Loop
    End With
 
Briguy2k

Welcome to the MrExcel board!

I haven't tested the code but I have two suggestions.

1. Change Shift:=x1up to Shift:=xlup

2. Declare another variable (say r as integer) and set it as follows
r = rngFind.Row

You should then be able to use r to help solve your problem.
 
Upvote 0

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
Back
Top