Input values in a column according to the reference from another column of the same sheet

nabilah

hi I have a problem in inputting values into a column with conditions and referring to the other 2 or more columns to determine the input of the other column using VBA. for example there are 3 columns called RAG cost (C), RAG Resources (R) and RAG Benefits (B). this 3 columns will determine the input value in a column called Overall RAG using VBA. for example if column (C) or column (B) contains the value"R" , then the overall RAG Status will be input as "A" in the respective rows. I tried using the if else statement but it doesn't seems to work. to make it clearer this is the example: if RAG Cost(C) OR RAG Resources(R) VALUES = "R" then Overall RAG status= "A".

Nitish

You don't need vba for this you can write a simple formula like

=IF(ISERROR(MATCH("R",B2:D2,0)),"","A")

If You want code please try this

Sub rgb()
Dim lstrow As Long
Dim i As Long
Dim LastCol As Long
Dim j As Long

lstrow = Range("B" & Sheets("Sheet1").Rows.Count).End(xlUp).Row
LastCol = Sheets("Sheet1").Cells(1, Sheets("Sheet1").Columns.Count).End(xlToLeft).Column
For i = 2 To lstrow
    For j = 2 To LastCol
        If ActiveSheet.Cells(i, j).Value = "R" Then
            Range("A" & i).Value = "A"
        End If
    Next j
Next i

End Sub

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

To create a column Summing the values from another column in the same view

How to find the top 5 values of a column according to another column?

Pandas: extract values from column, according to value of another column, and separate into separate dataframes

Create new column of closest values according to another column by groups

Updating a column in a dataframe with values from the same column another dataframe

Sorting unique values according to another column in pandas

How to replace all same values of a group in a column (dataframe) according to another column without loop?

Set values of column in dataframe according to the order of another column value in python

Use pandas to calculate month and week from a given date column in excel and append to another column in same sheet

How to populate or update column value in an excel sheet based on data values in another reference column

Google Sheet: How to extract all values from a column which fulfils a condition to another column in Googlesheet using formula?

Excel: Summing a column according to values in another column

how to copy text from column of active sheet and past it to another sheet according to the specific row and column number which are in active sheet

Derive column from values in another column in the same dataframe

Get list of values from multiple tabs and copy to a column in another sheet?

Copy a value from one sheet to another and then copy result back to same sheet in different column

Assign random values to column according to another column's values in R

MySQL : reference a column from another column

Find values from one column in another column according to ID in r

How to copy data from one sheet using column name and paste to another sheet with same column name?

From Pandas Dataframe find unique values in column and see if those values have the same values in another column

Add values from one column to another based on a reference [Excel]

If two values in the same column match, return value from the same row from another column

Append values from one column to another JSON column in the same dataframe

Copying visible data from one filtered column to another in the same sheet as values

Query to insert values in a column, according to the value of another column

How do you populate a google sheets/excel column with cells from a column in another sheet in the same document?

Copy / paste background color from one column to another sheet in a column with matched values

Copy column data from one sheet to another sheet if values in key column matches