Inherit Cell Colour Using VBA - vba

I have a vlookup formula that is pulling results from table A and the cell that contains the results are coloured differently. I would like the colour of the cell to be inherited from table A to table B.
What would be the VBA formula to achieve this please?
Many thanks!

Related

Excel formula into all cell array

Im trying to fill in a formula in a lot of cells using a VBA. The workbook I'm working with looks like this:
I'm trying to fill in a formula starting in B3. I first tried to define a range and insert formula, but my problem is that the range is never the same. Some data sets I have more columns and others i have more rows.
Is there a way to make a VBA that defines the range as all columns with content in Row1 and all rows with content in A?
The formula that I'm trying to inset is like this: =INDEX(Sheet1!$N:$N;MATCH(Sheet3!$A:$A&Sheet3!B$1;Sheet1!$R:$R;0))
I hope someone can help me with my problem.
you could create a dynamic named range that can be used in VBA
Use the below to define the range
=OFFSET(Sheet1!$B$3,0,0,COUNTA(Sheet1!$A:$A)-1,COUNTA(Sheet1!$1:$1)-1)
Changing Sheet1 to that of your sheetname
Assuming that there areno blank columns or rowsin your data set etc.

Formulas to Switch Row and Column References in Excel

I have raw data that is arranged like this:
The top row is the trial number. Then the first entry in each row is an ID.
I'm trying to set up a template for this data. When this data is pasted in, I want it to be read by another sheet. This sheet will automatically transpose the data, so that it looks like this:
On this sheet, then, I've been trying to write a formula that will increment horizontally when dragged down vertically. When I copy the formula horizontally, I would need it to increase the row reference, not the column reference, so that it'll reproduce the end result in the screenshot above.
I've tried variations on a formula like
INDEX('Asset Returns'!$B$2:$Z$2,COLUMN()-1,ROW()-1)
but I haven't been able to get it working as described. Thanks in advance for any suggestions on what I'm doing wrong.
Not sure if I've understood, but if what you're doing is transposition, but wanting to do it via a common forumla in all the destination cells, you can do it using this:
=INDIRECT(ADDRESS(COLUMN(A1),ROW(A1),1,1,"Asset Returns"))
This should be pasted into the A1 cell of your "transposed" sheet, or adjust the cell reference accordingly if that isn't where the data is.
Another option is:
=OFFSET('Asset Returns'!$A$1,COLUMN(A1)-1,ROW(A1)-1)

using SQL query to populate Excel cell

How can I have a cell populated by a sql query?
For example, if a user manually input a part number into cell A1, cell A2 would populate by completing a query using A1 as a parameter.
Something like:
=select table.desc from table where table.partNo = 'A1'
Hope this makes sense.
Depends whether you want to populate cell by cell or by range.
I have used EPPlus along with C# to populate excel templates.
In our case the values are stored in database after the rule evaluation for each cell and then its either gets displayed on screen or exported to excel.
Its not a few lines of code which I can paste it here but you can try below:
1. Define rules with the sql criteria and definition that defines the coordinates of cell
2. Evaluate rules and persist the values
3. Display the values
Ping me if you need more help on this

Changing Formula sheet reference with Macro

Hello everyone i'm new to this site! i wanted to see if anyone could assist with a concept i believe is possible but don't know how to achieve it.
Essentially i have a formula that has Vlookups and references other sheets, this formula is the same but the sheet referenced changes for each column as each column references a different sheet. this is going to be done 135 times over 8 times.
=IF((IFERROR(VLOOKUP(D3,'[2015_Big_Book_Communication_10_19_15.xlsx]**Credit P-1**'!$C$2:$O$5000,9,FALSE),"Not Scheduled"))=0,1,IFERROR(VLOOKUP(D3,'[2015_Big_Book_Communication_10_19_15.xlsx]**Credit P-1**'!$C$2:$O$5000,9,FALSE),"Not Scheduled"))
I want to use a macro to change the bolded sheet reference based upon a cell.
my idea is to have all the sheet names listed in a column and have the macro edit the equation for each row and then just paste the formulas transposed.
Is this possible?
Use the following formula:
=IF((IFERROR(VLOOKUP(D3,INDIRECT("'[2015_Big_Book_Communication_10_19_15.xlsx]"&H3&"'!$C$2:$O$5000"),9,FALSE),"Not Scheduled"))=0,1,IFERROR(VLOOKUP(D3,INDIRECT("'[2015_Big_Book_Communication_10_19_15.xlsx]"&H3&"'!$C$2:$O$5000"),9,FALSE),"Not Scheduled"))
In a column ("col H" in this example) write the sheet names and use indirect formula to refer to those names.

Spliting cells in excel based on some parameter

I wanted to know who can the following content be split in to two cells:
if i have C:\Pgm\Win\a1.c
in one cell
how can i split it in to two cells
C:\Pgm\Win a1.c
In my excel I have around 500 such rows.Is their any key availabe to do. I am using excel 2007.
You can use formulas to do the split
Assuming first string is in cell A1, place these formulas
Cell B1
=LEFT(A1,FIND("*",SUBSTITUTE(A1,"\","*",LEN(A1)-LEN(SUBSTITUTE(A1,"\",""))))-1)
Cell C1
=RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1,"\","*",LEN(A1)-LEN(SUBSTITUTE(A1,"\","")))))
Copy down for all data rows
Once these formulas are calculated, you can copy/paste values and delete the original data if required
by using data to columns ....we can get...in to multiple columns...but it will not be an 100% solution