# In VBA store the a row ref based on a value entered

#### markh1182

##### New Member
Hi,

I have this code that runs, and if the If criteria is met, it runs and writes in To Summary. Is it possible to capture the row reference of this cell, so it can be used in a formula, then this repeats?

Code:
``````Sub Summary()

FinalRow = ActiveSheet.Range("J65536").End(xlUp).Row

Dim HeadHeight As Double
Dim tHeight As Double
Dim n As Long
HeadHeight = Cells(1, 1).RowHeight
tHeight = 0
For n = 1 To ActiveSheet.UsedRange.rows.Count
tHeight = tHeight + Cells(n, 1).RowHeight
If tHeight > (752.25 + HeadHeight) Then

If Application.WorksheetFunction.Count(rows(n - 1 & ":" & n - 58)) > 0 Then

If Range("J" & n - 1).Value <> "To Summary" Or Range("O" & n).Value <> "" Then
Range("J" & n - 1).EntireRow.Select
Selection.Insert Shift:=xlDown
Range("J" & n - 1).Value = "To Summary"
tHeight = HeadHeight + Cells(n, 1).RowHeight
End If
End If
End If
Next n
End Sub``````

### Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

#### venkat1926

##### Well-known Member
a guess only

dim cfind as range
dim j as integer
set cfind=cells.find (what::="To Summary",lookat:=xlwhole)
j=cfind.row

J will give you the row number
any othere cell in that cell you can use
cells(cfind.row,"D")
that is cfind row and column D.
There are many ways of doing this.

try something on these lines.

#### markh1182

##### New Member
Thanks for that. Looks like it is working and is a good starting point for what I want to achieve.

Replies
13
Views
449
Replies
4
Views
265
Replies
3
Views
794
Replies
0
Views
310
Replies
8
Views
223

1,172,017
Messages
5,878,757
Members
433,370
Latest member
mcleven

### 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?

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