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

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
890
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



<tbody>
[TD="class: xl63"]

<tbody>
[TD="class: xl65, align: center"][/TD]
[TD="class: xl65, width: 213, align: center"]B[/TD]
[TD="class: xl67, width: 592, align: center"]C[/TD]

[TD="class: xl65, align: center"]135[/TD]
[TD="class: xl65, align: center"]Occupancy[/TD]
[TD="class: xl67, align: center"]=VLOOKUP($D$1;[TABLE.xlsx]Sheet1!A3:M7;MATCH($D$6;[TABLE.xlsx]Sheet1!A1:M1;0);0)
[/TD]

[TD="class: xl65, align: center"]136[/TD]
[TD="class: xl65, align: center"][/TD]
[TD="class: xl67, align: center"][/TD]

</tbody>
[/TD]
[TD="class: xl65, width: 85"][/TD]

[TD="class: xl63, align: right"][/TD]
[TD="class: xl63"][/TD]
[TD="class: xl65, align: right"][/TD]

[TD="class: xl63, align: right"][/TD]
[TD="class: xl63"][/TD]
[TD="class: xl65"][/TD]

</tbody>
 

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.
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,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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