Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50162

Formula using vba to find last colrow

$
0
0
have included macro2 to set a target if it belongs to group id . but however the formula seems to work for the whole column even when the data is empty and show false. is there a way to fix this cause group seems to work.

col a = alm
col b =id
col c= date
col d= des
col e= LEFT($A2,4)
col f= =IF(E2="AIE1",9,IF(E2="AII1",35,IF(E2="AIM1",50,IF(E2="AIM2",6,IF(E2="ARE1",0)))))



Code:

Sub GROUP()
Dim LastRowColA As Integer
Sheets("Sheet1").Select
LastRowColA = Range("A65536").End(xlUp).row
Range("E2:E" & LastRowColA).Select
With Selection
.FormulaR1C1 = "=LEFT(RC1,4)"
End With

End Sub

Sub Macro2()
    Dim LastRowColF As Integer
    Sheets("Sheet1").Select
    LastRowColF = Range("A65536").End(xlUp).row
   
    Range("F2:F" & LastRowColF).Select
    With Selection
  .FormulaR1C1 = _
        "=IF(RC[-1]=""AIE1"",9,IF(RC[-1]=""AII1"",35,IF(RC[-1]=""AIM1"",50,IF(RC[-1]=""AIM2"",6,IF(RC[-1]=""ARE1"",0)))))"
  End With
 
End Sub


Viewing all articles
Browse latest Browse all 50162

Trending Articles