Hey all,
Need some assistance with a macro I am currently trying to formulate. I ususally use AutoFilter or IF Statements, so I am totally new to Case Select and need some basic help. To give some background info on what I'm working on, I have a file with various data. I need to create a Case Select to go through each row so to go from A2 (Since A1 is header) till the the last cell (End(xlDown) but Idk how to do that with Case Select) and then do something like the following:
- If Q2 = "Cash" AND J2 = "GC" then change cell A2 to "Capital Activity"
- If Q2 = "Bond Deals" AND B2 contains "CLO" (don't know how to do this in case select either) then change cell A2 to "CLO Subtype"
- If Q2 = "Bond Deals" AND R2 has 9 or 12 characters (don't know how to do this in case select either..use LEN?) then change cell A2 to "Bond"
If anyone can provide me with that I can figure out the rest of my macro on my own. I have provided my previous macro which got too messy/big/complicated which I tried to do the same thing using AutoFilter. After talking to one of my peers, he advised I look into using Case Select so that is why I am asking. Thanks in advance. I have also provided the file for viewing/using.
For The Q2 = Cash & J2 = "GC" > A2: Capital Activity
'Capital Activity Search ActiveSheet.range(Selection, Selection.End(xlUp)).AutoFilter Field:=7, Criteria1:="GC" range("B1").Select ActiveCell.Offset(1, 0).Select Do Until ActiveCell.Height <> 0 ActiveCell.Offset(1, 0).Select Loop If Not Selection.Offset(0, 1) = "" Then Selection.End(xlToLeft).Select Selection.End(xlDown).Select ActiveCell.FormulaR1C1 = "Capital Activity" Selection.Copy range(Selection, Selection.End(xlUp)).Select ActiveSheet.Paste Selection.End(xlUp).Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "'Subtype" End If ActiveSheet.ShowAllData
For The Q2 = Bond Deals & B2 containing "CLO" > A2: CLO Subtype
ActiveSheet.range(Selection, Selection.End(xlUp)).AutoFilter Field:=12, Criteria1:="BondsDeals" range("C1").Select ActiveSheet.range(Selection, Selection.End(xlUp)).AutoFilter Field:=3, Criteria1:="=*CLO *" ActiveCell.Offset(1, 0).Select Do Until ActiveCell.Height <> 0 ActiveCell.Offset(1, 0).Select Loop If Not Selection.Offset(1, 0) = "" Then Selection.End(xlToLeft).Select Selection.End(xlDown).Select ActiveCell.FormulaR1C1 = "CLO Subtype" Selection.Copy range(Selection, Selection.End(xlUp)).Select ActiveSheet.Paste Selection.End(xlUp).Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "'Subtype" End If ActiveSheet.ShowAllData
As you can see, my code is very messy and complicated. I would really appreciate help, and am more than ready to provide more information if needed. Here is the example file. Thanks In Advance!
https://www.dropbox.com/s/21xhnd8dz5kr9o5/CaseSelectEG.xlsx?m