I am just learning how to write macros and I need some help linking two If..then:..else statements.

I have two drop down boxes that I want to link together. I am trying to tell it that

if one statement is true then filter row
else filter for criteria cell (2, 4)

if one statement is true then filter row
else filter for criteria cell (3, 4)

But I don't know how to link them. I want both drop down boxes to loop together.

Thanks

Recommended Answers

All 4 Replies

I'm not 100% sure I know what you are asking.... if I'm missing the mark completely, let me know.... are you looking for an "elseif" type command?

Yeah I tried using that but it wasn't working. I ended up figuring it out but thanks for the help. I am teaching myself and trying to learn from picking apart my old teachers macros. But I am missing basic knowledge. I'm sure you will hear from me again soon and thanks for your help.

Can you tell us what the solution was?

Sure I don't care:

If Cells(2, 4) = "(ALL)" Then
           If Cells(3, 4) = "(ALL)" Then
            Selection.AutoFilter Field:=3
            Application.Run "HIDE_ROWS"
            Else
            Selection.AutoFilter Field:=3, Criteria1:=Cells(3, 4)
            End If
                       
    Else
        Selection.AutoFilter Field:=2, Criteria1:=Cells(2, 4)
        
            If Cells(3, 4) = "(ALL)" Then
            Selection.AutoFilter Field:=3
            Else
            Selection.AutoFilter Field:=3, Criteria1:=Cells(3, 4)
            End If
            
        
        End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.