Results 1 to 21 of 21

Using Case Select On Range With Multiple Conditions?

Threaded View

  1. #1
    Registered User
    Join Date
    06-05-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    39

    Using Case Select On Range With Multiple Conditions?

    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/21xhnd8dz5...electEG.xlsx?m

    Also, have posted problem on friend site OzGrid: http://www.ozgrid.com/forum/showthre...371#post672371
    Last edited by alulla; 07-03-2013 at 11:37 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1