Help with Indexing in VBA

shiva_reshs

Board Regular
Joined
Sep 5, 2012
Messages
68
Hello,

I am not able to figure out, what is wrong in this Indexing code.

Code:
<code>Range("R6").Select ActiveCell.FormulaR1C1 = "=IF($Q6="","",INDEX('Worker-Exempt'!B:B,MATCH($Q6,'Worker-Exempt'!A:A,0)))"</code></pre>

I get application 1004 error msg.

Cross Posting

HTML:
http://www.excelforum.com/excel-programming-vba-macros/960412-vlookup-to-index-matching-in-vba.html
 
Need your help again..

Your code helps to change cell value to "-" for every #n/a, but is it possible to highlight the cell to color which do not have #n/a ??
Hard to know exactly what you want given there are two different code responses to your two questions. I'll assume the original (corrected) response by me is the one you want modified. Give this a try...

Code:
With Range("N6:N" & lr1)
    .Formula = "=IF($L6="""","""",INDEX('US Exempt Worker- US Exempt Wor'!C:C,MATCH($L6,'US Exempt Worker- US Exempt Wor'!B:B,0)))"
    .Value = .Value
    .Interior.ColorIndex = 5
    On Error Resume Next
    With .SpecialCells(xlConstants, xlErrors)
      .Value = "-"
      .Interior.ColorIndex = xlColorIndexNone
    End With
    On Error GoTo 0
End With
 
Upvote 0

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Thanks Rick. This is what I wanted..

But I am not able to replicate your code on below VBA

Code:
With Range("S6:S" & Range("R" & Rows.Count).End(xlUp).Row)
   .FormulaR1C1 = "=IF(Round(RC[-1]-RC[-3],2)=0,""Perfect Match"",RC[-1]-RC[-3])"
   .Value = .Value
   .FormatConditions.Delete
   .FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, Formula1:="=""Perfect Match"""
End With

Above VBA simply does minus formula, and when there is return value of "Zero" it display a cell value as "Perfect Match"

I am trying to replicate your code, so whatever it is not perfect match I need a color highlighted in those cell.

Thanks.
 
Upvote 0

Forum statistics

Threads
1,215,459
Messages
6,124,947
Members
449,198
Latest member
MhammadishaqKhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top