Specific VBA Macro for Selecting Rows Containing Cells with Formulas, and the 2 rows below

stevefilcher

New Member
Joined
Dec 29, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Is there a way to write a VBA macro that would find and select all cells with formulas, and then select the row holding those cells, and the two rows below it?

And if that's not possible, would there be a way to simply hotkey Find & Select cells containing formulas?

Cannot seem to figure it out, any help is greatly appreciated! Thanks!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Sure but you need to eleborate on what you want to do.
VBA
VBA Code:
Sub SelectFormulas()

    Dim rng As Range
    Dim rRow As Range
    Dim rRowGrp As Range
    
    ' Set rng to all cells containing formulas
    Set rng = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas)
    
    Debug.Print rng.Address                                                ' XXX for testing show selection in the immediate window
    
    For Each rRow In rng.Rows
        ' select current row + next 2 rows
        Set rRowGrp = rRow.Resize(3)
        Debug.Print rRow.Address, rRowGrp.Address           ' XXX for testing show selection in the immediate window
    Next rRow

End Sub

Manually
Ctrl+F >
Find What > "=" without the quotes
Look in > Formulas
Then Ctrl+A in the found box
 
Upvote 0

Forum statistics

Threads
1,214,545
Messages
6,120,132
Members
448,947
Latest member
test111

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