Solved

function to enter formula in cells down a column based on cell color

Posted on 2011-09-08
8
279 Views
Last Modified: 2012-05-12
excel 2003 vba
routine needed:

I have a "sheet1" with lookup data for sheet "UnSolicated_Projects".
On sheet "UnSolicated_Projects"
I have Gray rows as seperator
RGB(194, 194, 194)

On sheet "UnSolicated_Projects"
In ColumnB STARTING IN B2(but not always on B2) I need a formula inserted.
=VLOOKUP(A2,Sheet1!$A$2:$CO$11628,74,FALSE)
evertime there is a gray row , Underneath the gray cell THE formlua TO BE ADDED:

caveat:
Sometimes I may have  4 gray lines in a row

so the first row may be B5
=VLOOKUP(A5,Sheet1!$A$2:$CO$11628,74,FALSE)
 
Either way I need this formula added to ColumnB below a Grayline if the cell background is "NoFill"
Until the end of the rows.

The number of rows will always be different for each execution of the sub routine.

Then execute the formula

Thanks
fordraiders







FormulaCodeSS.png
0
Comment
Question by:fordraiders
  • 5
  • 3
8 Comments
 
LVL 33

Expert Comment

by:Rob Henson
ID: 36505565
Does column A always start with CRS for a total row?

Is the CRS name constant in column C?

If so you could an IF statement:
 =IF(LEFT($A2,3)="CRS",SUMIF($C$1:$C1,$C1,$B$1:$B1),VLOOKUP($A2,Sheet1!$A$2:$CO$11628,74,FALSE))

Copy down and then apply conditional formatting based on the CRS again for the total rows.

Thanks
Rob H
0
 
LVL 3

Author Comment

by:fordraiders
ID: 36506018
Does column A always start with CRS for a total row?   YES

Is the CRS name constant in column C?  YES

But I need vba function...this needs to be automated via a sub routine...not manual please


0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 36506837
Can I ask why it has to be vba if the formula is working?

The population of the formula down the column as the data expands could be automated if you wanted.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 3

Author Comment

by:fordraiders
ID: 36507218
because my folks are using this sheet not me , and they do not do anything manual
0
 
LVL 3

Author Comment

by:fordraiders
ID: 36507463
WITHOUT HAVING TO WORRY ABOUT THE COLOR ROW.

this almost works
Application.ScreenUpdating = False
Sheets("UnSolicated_Projects").Select
Dim LastRow As Long
LastRow = Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
Range("B2:B" & LastRow).FormulaR1C1 = "=VLOOKUP(R[ACTIVECELL.ROW],Sheet1!$A$2:$CO$11628,74,FALSE)"
Application.CutCopyMode = False
Application.ScreenUpdating = True
0
 
LVL 3

Author Comment

by:fordraiders
ID: 36508157
this works.

Application.ScreenUpdating = False
Sheets("UnSolicated_Projects").Select
Dim LastRow As Long
Dim j As Integer
j = ActiveCell.Row
LastRow = Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows).Row
Range("B2:B" & LastRow).Formula = "=VLOOKUP(A2,Sheet1!$A$2:$CO$11628,74,FALSE)"
Application.CutCopyMode = False
Application.ScreenUpdating = True
0
 
LVL 33

Accepted Solution

by:
Rob Henson earned 500 total points
ID: 36509187
You could use fordraiders routine to populate my suggested formula by changing:

Range("B2:B" & LastRow).Formula = "=VLOOKUP(A2,Sheet1!$A$2:$CO$11628,74,FALSE)"

to

Range("B2:B" & LastRow).Formula = "=IF(LEFT(R[ACTIVECELL.ROW],3)="CRS",SUMIF(R1C3:R[-1]C3,R[-1]C3,R1C2:R[-1]C2),VLOOKUP(R[ACTIVECELL.ROW],Sheet1!$A$2:$CO$11628,74,FALSE)"

Thanks
Rob H
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 36525141
Thanks
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Batch Numbering 6 30
get the ALL CAPITAL words from a cell 4 19
MS Excel Formula Help 3 32
Excel Formula for Commission Structure 2 17
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question