Select/Highlight Columns in Excel 2010 Based on Their Addresses [closed] - excel

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I have a column in Excel which contains the addresses of the cells that need to be selected and then highlighted. Please find below a snapshot:
Col# Row# Corresponding Address
8 1 $H$1
9 2 $I$2
10 3 $J$3
10 4 $J$4
9 5 $I$5
10 6 $J$6
10 7 $J$7
10 8 $J$8
11 9 $K$9
12 10 $L$10
12 11 $L$11
11 12 $K$12
As an example, I need to select cell $H$1 and highlight it.
I would like to perform this task automatically for a large matrix. What would the vba code be for this task?
Any help is highly appreciated

You would need to loop through the Corresponding Address column and set, (assuming that you want the cell colour changed in order to highlight it) the Interior.Colour to a RGB value:
Dim x As Worksheet, y As Worksheet
Dim CtrA As Long
Set x = Worksheets("SheetName1")
Set y = Worksheets("SheetName2")
For CtrA = 2 To x.Rows.Count
y.Range(x.Range("C" & CtrA)).Interior.Color = RGB(0, 255, 0)
Next
where x is a reference to the sheet containing the table in your question, and y is a reference to the sheet that contains the cells you want to highlight.

Related

Can Nested if be applicable to filter dynamically changing range in excel [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 11 months ago.
Improve this question
Consider a data table in excel with 6 columns Min, Max, x, 17,18,19 and 3 user input. Output expected is an appropriate cell value to be returned from the table
when
my first userinput value lies within Min and Max(from table)
2nd user input value matching any of the cell in column x
3rd user input matching either 17/18 or 19
For Eg
Sample Data:
Min Max x 17 18 19
-------------------
1 7 0.5 1 2 3/n
8 10 1 2 5 7/n
8 10 2 8 4 9/n
8 10 3 0 7 4/n
11 12 0.5 3 2 1/n
If my user input is (8.4,2,18)
output expected is 4
=INDEX(D2:F6,SUMPRODUCT((A2:A6<=A9)*(B2:B6>=A9)*(C2:C6=A10)*ROW(A2:A6))-ROW(A1),MATCH(A11,D1:F1,0))
Where SUMPRODUCT calculates the row number meeting conditions for min, max and x minus the row number of the header row for correct indexing.
Match calculates the column for indexing.

Function or code to compare multiple sheets in Excel and display them sorted in ascending order in a new sheet [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a workbook which has let's say 3 similar worksheets. Each from different supplier. I want to compare them to find out who is cheaper and who is the cheapest with each and every item.
For example:
Worksheet 1 (D) (stands for David)
A B C D
1 quality 1 quality 2 quality 3 .....
2 Apple 20 30 40
3 Orange 25 33 46
Worksheet 2 (O) (stands for Oliver)
A B C D
1 quality 1 quality 2 quality 3 .....
2 Apple 18 30 35
3 Orange 25 35 46
Worksheet 3 (H) (stands for Harry)
A B C D
1 quality 1 quality 2 quality 3 .....
2 Apple 22 33 44
3 Orange 20 36 39
I expect the output to be something like this:
Worksheet 4 (sorted by the cheapest)
A B C D
1 quality 1 quality 2 quality 3 .....
2 Apple O;D;H D=O;H O;D;H
3 Orange H;D=O D;O;H H;D=O
Thanks in advance for your time and consideration.
What's tough about this one is that Excel ranges can't really cross worksheets, it isn't really 3D. So in VBA you'll probably end up with:
An Array of sheet names for your 3 (or more?) sheets to be compared
A loop to pull the values from a given 2D address across the array of sheets into an Array
Sort the Array (which isn't a thing, you have to dump the array into a temp range somewhere and sort that, along with a list of sheet names)
A loop to go down the sorted array's temp range, naming the sheets in order and putting in either an equals sign or semicolon depending on the next value
which all constructs a string of the type in your output sheet.
...I'd do all that as an Excel function, then copy the function into all the cells of Sheet4, since the names of sheets1-3 are hard-coded into the function.
If you want to be able to do this for any arbitrary list of sheets, trickier still.
But before we get into that, do you have a lot of this 3D data processing to do? Because Excel has a powerful tool for multi-dimensional data, called a Pivot Table, and your data is eminently suitable for putting into a pivot table, and this would allow you to "pivot" the data so that "which supplier" becomes a column or row, rather than sheet.
Pivot tables have a learning curve, but they're the way to go for this kind of problem.

How can I SUMIFS where criteria is a set of numbers from a column? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have an Excel file that looks like this:
ZONES Count Area 1 = (SUM OF ZONE COUNT)
------------------------------------------------------------------------------
1 100 1
2 50 2
3 110 5
4 90 7
5 40
6 10
7 0
8 80
What I need to do is make (SUM OF ZONE COUNT) say 190 since 100+40+50+0 = 190. I've tried:
=SUMIFS(B3:B10, A3:A10, C3)
And it will return 100. When I try:
=SUMIFS(B3:B10, A3:A10, "="&C3:C6)
It returns 0.
I need to set the criteria to be a range instead of an individual cell.
Is this possible?
Try this version
=SUMPRODUCT(SUMIFS(B3:B10,A3:A10,C3:C6))
because the criteria range is four cells the SUMIFS function will return an "array" of four values - SUMPRODUCT is used to sum those four values
You can also use SUM but the formula needs to be "array entered", i.e.
=SUM(SUMIFS(B3:B10,A3:A10,C3:C6))
confirm with CTRL+SHIFT+ENTER

Excel - Search through a column to find if text matches and then add corresponding cell [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to add values from 1 worksheet to another.
The first worksheet ("November 2011") simply contains name & price, names are however duplicated and the sum needs to be added on the second worksheet ("Sales").
e.g. "November 2011"
A B
1 Name Price
2 McDonalds 10
3 McDonalds 10
4 Burger King 20
5 Burger King 30
6 Wendys 5
7 iHop 20
8 iHop 15
The second worksheet ("Sales") contains only 2 columns also Name & Price. However, Name has had duplicates removed.
e.g. "Sales"
A B
1 Name Price
2 McDonalds
3 Burger King
4 Wendys
5 iHop
I need a formula to sum the totals from the first worksheet "November 2011" onto the Price for the second worksheet "Sales".
I have used this formula =IF(ISNUMBER(SEARCH(A2,Sales!A1:A8)),'November 2011'!D2,"") but it only matches the text for a single row.
What I want is a formula which does this:
"Sales"
A B
1 Name Price
2 McDonalds 20
3 Burger King 50
4 Wendys 5
5 iHop 35
Try using SUMIF, which takes the following format:
=SUMIF(<some_range>, <some_critiera>, <range_to_sum>)
In your case, you would put this formula in cell B2 on the sheet Sales:
=SUMIF('November 2011'!$A$2:$A$8,A2,'Nov 2011'!$B$2:$B$8)
Or to make it a bit more flexible by incorporating the entire range:
=SUMIF('Nov 2011'!A:A,A2,'Nov 2011'!B:B)

Add if row contains a string in excel [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Without the use of macros or anything fancy, is it possible to write an excel formula that would add up Col-1 rows that correspond to Col-2 rows having the string 'st'?
+----+-------+-------+
+ # + Col-1 + Col-2 +
+----+ ------+-------+
+ 1 + 1 + an st +
+ 2 + 2 + f st +
+ 3 + 1 + st fr +
+ 4 + 1 + bd bd +
+----+-------+-------+
So in this example, it should add up rows 1,2 and 3 and return 1+2+1 = 4
There is a way. Use this: =SUMPRODUCT(ISNUMBER(FIND("st",B1:B4))*A1:A4)
Why do we not just use:
=SUMIF(B1:B4,"*st*",A1:A4)
I'd introduce a third column. The values of the third column will be the one of the first if the second contains the string, 0 otherwise.
Summing up the values in the third column will return the result you want.
If you don't like to display or print the column you introduce you should hide it.
Assuming the first row is in Row 1, starting at column a, you can add another column to the right which checks for each, using this formula:
=IF(ISNUMBER(SEARCH("st", C1)), B1, 0)
That should return 1, 2, 1, 0 respectively for your rows.
Sum that column for the total.

Resources