VBA macro for multiple values

GeorgesT

New Member
Joined
Mar 20, 2013
Messages
7
Hi,

Im struggling with this code:

Code:
On Error Resume Next</SPAN></SPAN>
 
Dim PSL As Long</SPAN></SPAN>
Dim i As Long</SPAN></SPAN>
Dim y As Variant</SPAN></SPAN>
 
PSL = Range("T" & Rows.Count).End(xlUp).Row</SPAN></SPAN>
For Each y In Range(PSL)</SPAN></SPAN>
 
 
    If Sheets("ProjectRegister").Cells("T" & i).SpecialCells(xlCellTypeConstants).Value = "Completed" _</SPAN></SPAN>
        And Sheets("ProjectRegister").Cells("Z" & i).SpecialCells(xlCellTypeConstants).Value = "Yes" _</SPAN></SPAN>
        Then Sheets("ProjectRegister").Rows(i).Hidden = True</SPAN></SPAN>
   
   
Next y</SPAN>

The code hides everything from the last found value and does not care what the value is.

Can someone help me please?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
* It looks like variable "i" is not defined.
* It looks like it is evaluating only one cell even though you have a loop
 
Upvote 0
I solved it

Code:
                ' The Double is Hide function
Dim i As Long
Dim j As Variant

                'Always needed this line for a For Next loop
On Error Resume Next
                'Range for the itteration
For i = 0 To 2000
                'First Case, cell value is Completed
Select Case Worksheets("ProjectRegister").Cells(i, 20).Text
Case Is = "Completed"
                'When so, it moves to the second case
j = Worksheets("ProjectRegister").Cells(i, 26)
    Select Case j
    Case Is = "Yes"
                'If it is Yes, it hides
    Rows(i).EntireRow.Hidden = True
    End Select
End Select

How to make the range dependend on column B end(xlup)?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,895
Messages
6,122,128
Members
449,066
Latest member
Andyg666

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