Solved

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

Posted on 2011-09-08
8
260 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 32

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 32

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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 32

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

948 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

21 Experts available now in Live!

Get 1:1 Help Now