Solved

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

Posted on 2011-09-08
8
251 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 31

Expert Comment

by:Rob Henson
Comment Utility
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
Comment Utility
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 31

Expert Comment

by:Rob Henson
Comment Utility
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
 
LVL 3

Author Comment

by:fordraiders
Comment Utility
because my folks are using this sheet not me , and they do not do anything manual
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Author Comment

by:fordraiders
Comment Utility
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
Comment Utility
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 31

Accepted Solution

by:
Rob Henson earned 500 total points
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
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…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now