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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hello,

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

Hope this will help
 
Upvote 0

Forum statistics

Threads
1,223,754
Messages
6,174,317
Members
452,555
Latest member
colc007

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