Loop with two arguments

vck2017

New Member
Joined
Jan 13, 2017
Messages
8
Hello, I am using a loop function to select a range of rows with x marked in two columns, i.e. with two conditions. I have tried many different things putting an And function but noting works. I highly appreciate if anyone can advise


Code:
    If ActiveSheet.ToggleButton1 = True Then
    
    For Each c1 In Range(Cells(StartR, 2), Cells(StartR + Size - 1, 2)) And For Each c1 In Range(Cells(StartR, 2), Cells(StartR + Size - 1, 2))

    If c1.Value = "x" Then
    c1.EntireRow.Hidden = False
    If Rng Is Nothing Then Set Rng = c1 Else Set Rng = Union(Rng, c1)
    End If
    Next c1
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hello,

You could make your life somewhat easier by using AutoFilter ...

Hope this will help
 
Upvote 0

Forum statistics

Threads
1,225,626
Messages
6,186,090
Members
453,337
Latest member
fiaz ahmad

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top