?
Solved

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

Posted on 2011-09-08
8
Medium Priority
?
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

752 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