Posting formulas in cells

JARichard74

Board Regular
Joined
Dec 16, 2019
Messages
114
Office Version
  1. 365
Platform
  1. Windows
Trying to put the formula in cells C4,C5,C6 and then C8, C9, C10. proptbl.ListRows.Count is the number of proponents i.e. in this example = 3
VBA Code:
For b = 1 To 2
ThisWorkbook.Worksheets("Price").Range("C" & b * 4 & ":C" & 3 + proptbl.ListRows.Count).Formula = "=VLOOKUP($B4,Data!$G$3:$I$13,3)"
Next b
 

Attachments

  • Screenshot 2020-12-18 180759.png
    Screenshot 2020-12-18 180759.png
    19.3 KB · Views: 5

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try:
VBA Code:
[C4].Resize(3) = "=VLOOKUP(B4,Data!$G$3:$I$13,3)"
[C8].Resize(3) = "=VLOOKUP(B8,Data!$G$3:$I$13,3)"
 
Upvote 0
Works however how would I make it so that it adjusts based on the number of proponents and criteria e.g. 3 criteria and 4 proponents. See attached. Number of proponents could be as high as 40
 

Attachments

  • Screenshot 2020-12-18 180760.png
    Screenshot 2020-12-18 180760.png
    24.2 KB · Views: 4
Upvote 0
Sorry, I don't understand what you mean by "it adjusts based on the number of proponents and criteria e.g. 3 criteria and 4 proponents."
It adjusts exactily what? You mean adjust the range that will receive the formulas or you mean adjust any parameters in the context of the formula?
In which cells should the code read the "criteria" and "proponents" values? Give us examples, please.
 
Upvote 0
If you look at the picture on my previous post I now have Proponent1, 2,3,4 as well as an extra line Row 13. The code puts the formula where it says #N/A. The number of criteria is
y = ThisWorkbook.Worksheets("Prep").Range("E7").Value ; and the number of proponent is z - 1. The C and B values would need to adjust based on y and z
VBA Code:
[C4].Resize(z - 1) = "=VLOOKUP(B4,Data!$G$3:$I$13,3)"
[C9].Resize(z - 1) = "=VLOOKUP(B9,Data!$G$3:$I$13,3)"
[C14].Resize(z - 1) = "=VLOOKUP(B14,Data!$G$3:$I$13,3)"

Something like this which I tried but gives a syntax error
VBA Code:
For i = 1 To y
[C & z * i - 1].Resize(z - 1) = "=VLOOKUP("B"& z * i - 1,Data!$G$3:$I$13,3)"
Next i
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,869
Members
449,054
Latest member
juliecooper255

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