Macro- Select the range for formula

ffionnah

Board Regular
Joined
Jun 12, 2018
Messages
61
Hi All,
I have a hodgepodge macro I am trying to write and I need help understanding how to merge the selecting range with the formula I want applied. Essentially, I want to select a range of data and have the formula populate the corresponding fields. I know I am missing something.. I just have no idea what it is! So far I have :

Code:
Sub MatchName()


Dim Rng As Range
Dim ThisRng As Range
Set ThisRng = Application.Selection
Set ThisRng = Application.InputBox("Range", ThisRng.Address, Type:=8)
Application.ScreenUpdating = False
For i = ThisRng.Rows.Count To 2 Step -1
 ActiveCell.FormulaR1C1 = _
        "=IFERROR(IF(MATCH(RC[-1],'[Master Database July 2018.xlsm] CONCAT LIST'!R2C1:R101C1,0),""yes"",""no""),"""")"
    Range("BA2").Select
    Selection.AutoFill Destination:=Range("BA2:BA305")
    Range("BA2:BA305").Select
Next
Application.ScreenUpdating = True


End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Well, I must have started writing this and then did not add it in. I'm not sure how to include it into the formula.

Code:
 For i = ThisRng.Rows.Count To 2 Step -1
 
Upvote 0
If anyone is interested; i figured it out; here is the full code:

Code:
Sub MatchName()


Dim Rng As Range
Dim ThisRng As Range
Set ThisRng = Application.Selection
Set ThisRng = Application.InputBox("Range", ThisRng.Address, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ThisRng
 ActiveCell.FormulaR1C1 = _
        "=IFERROR(IF(MATCH(RC[-1],'[Master Database July 2018.xlsm] CONCAT LIST'!R2C1:R101C1,0),""yes"",""no""),"""")"
    Range("BA2").Select
    Selection.AutoFill Destination:=Range("BA2:BA305")
    Range("BA2:BA305").Select
Next
Application.ScreenUpdating = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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