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

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

Jubjab

Well-known Member
Joined
Jan 3, 2007
Messages
995
* It looks like variable "i" is not defined.
* It looks like it is evaluating only one cell even though you have a loop
 

GeorgesT

New Member
Joined
Mar 20, 2013
Messages
7
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:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,632
Messages
5,838,474
Members
430,549
Latest member
jayjay2022

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
Top