Hi,
I have a large spreadsheet with a quarters worth of financial transactions. One of the columns contains a description, which is overly complicated and mostly irrelevant. What I would like to have is an additional column that can search for keywords within the descriptions column and then output the relevant text to the new column. So I guess, grouping several description keywords into group. I can then filter on the new group names far easier.
For example one description reads “OS PAYPAL,processed on 29.07.13” all I am bothered with is the PAYPAL detail in this line and it needs to be translated in the new column to TAKINGS
I have managed to put together the following VB, which works great, however it outputs the keywords to different columns. I have tried putting the .Formula statements within the same With/End With group but only the last run .Formula sticks in the correct column.
My question is, can all of these Ifs/CountIFs be added into one .Formula, or is there a better way of doing it?
Sub Sorting()
With Range("G1:G16357").Offset(, 5)
.Formula = "=IF(COUNTIF(RC[-5],""*test1*"")+COUNTIF(RC[-5],""*test2*"")+COUNTIF(RC[-5],""*test3*"")+COUNTIF(RC[-5],""*test4*"")+COUNTIF(RC[-5],""*test5*"")+COUNTIF(RC[-5],""*test6*""),""TAKINGS"","""")"
End With
With Range("G1:G16357").Offset(, 6)
.Formula = "=IF(COUNTIF(RC[-6],""*test7*"")+COUNTIF(RC[-6],""*test8*"")+COUNTIF(RC[-6],""*test9*""),""great"", """")"
End With
With Range("G1:G16357").Offset(, 7)
.Formula = "=IF(COUNTIF(RC[-7],""*bon*""),""BON"","""")"
End With
With Range("G1:G16357").Offset(, 8)
.Formula = "=IF(COUNTIF(RC[-8],""*income*""),""INCOME"","""")"
End With
With Range("G1:G16357").Offset(, 9)
.Formula = "=IF(COUNTIF(RC[-9],""*paye*""),""PAYE"","""")"
End With
With Range("G1:G16357").Offset(, 10)
.Formula = "=IF(COUNTIF(RC[-10],""*Payroll*""),""Payroll"","""")"
End With
End Sub
Bookmarks