Find specific text "Occupancy" and prepare formula in adjacent cell

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
882
Hi all, i would like to write a vba so that to run through col. "B" and where find the text "Occupancy" should write down a formula in col. "C" as my below extract. Note that the row of text "Occupancy" change each time when i download the data through accounting system.

Thanking you in advance


BC
135Occupancy=VLOOKUP($D$1;[TABLE.xlsx]Sheet1!A3:M7;MATCH($D$6;[TABLE.xlsx]Sheet1!A1:M1;0);0)
136

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
something like this:

Code:
Range("B1:B1000").Find("Occupancy").Offset(, 1).FormulaLocal = "=VLOOKUP($D$1;[TABLE.xlsx]Sheet1!A3:M7;MATCH($D$6;[TABLE.xlsx]Sheet1!A1:M1;0);0)"
 
Upvote 0
Code:
Sub ft()
[B:B].Find("Occupancy")(1, 2).Formula = _
    "=VLOOKUP($D$1;[TABLE.xlsx]Sheet1!A3:M7;MATCH($D$6;[TABLE.xlsx]Sheet1!A1:M1;0);0)"
End Sub
 
Upvote 0
Hi foot, It works perfect! Thank you so much for your support and your time. In addition i express my best wishes for the new year!
 
Upvote 0
Hi Vbagreen, The code block and it appears the following message:
"Run-time error 1004"
"Application-defined or object-defined error"

However i would like to thank you for your support and my best wishes for the new year
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,816
Members
449,469
Latest member
Kingwi11y

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