Note that there are some explanatory texts on larger screens.

plurals
  1. POMacro that populates values in specific column according to another column
    primarykey
    data
    text
    <p>I would like to ask for a help. I’m looking for a macro which would do such action:</p> <p>I have a column called Comment and five other columns which should be populated according to the Comment column. If in Comment column there is a message “duplicate” I would like to mark in column called Duplicate 1 if not it should be 0. Also in this case it happens that two values can indicate 1 to be populated – i.e. Left - Replacement Found and Left - No Replacement. For both of those values It should be 1 populated in the Left Column, for others 0.</p> <p>I modified macro which I have for Vlookup and I was able to get if function but only for 1 specific logical test (in this example "Left - Replacement found). I would need to have more than 1 logical test. So in this case I would like to have Left - Replacement Found and Left - No Replacement marked as 1 and the rest as 0.</p> <pre><code>Sub Testing_if_function() Dim FormulaCol As Long Dim LookupCol As Long Dim TotalRows As Long Dim TotalCols As Long Dim i As Long Sheets("Data").Select TotalRows = ActiveSheet.UsedRange.Rows.Count TotalCols = ActiveSheet.UsedRange.Columns.Count For i = 1 To TotalCols If Cells(1, i).Value = "Test" Then FormulaCol = i If Cells(1, i).Value = "Comment" Then LookupCol = i Next ActiveCell.FormulaR1C1 = "=IF(RC[-2]=""Left - Replacement Found"",1,0)" Cells(2, FormulaCol).AutoFill Destination:=Range(Cells(2, FormulaCol), Cells(TotalRows, FormulaCol)) With Range(Cells(2, FormulaCol), Cells(TotalRows, FormulaCol)) .Value = .Value End With End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload