Hide Unhide cells based on criteria of the rows cells then loop to next row

slayer1957

Board Regular
Joined
Jan 9, 2017
Messages
50
I have a rows specified, myvalue1 to myvalue2, i can enter any values via input box to print each page

I want vba text to check in the specified rows as above, in columns J-L ( i just want to it to loop through each row, then the columns checking for x and for each x it must hide certain rows which is different for each cell value of x

if there is an "X" in column J it must hide range of rows 1-10 on sheet1, if not then dont hide
if there is an "X" in column K it must hide range of rows 11-20 on sheet1, if not then dont hide
if there is an "X" in column L it must hide range of rows 21-30 on sheet1 ,if not then dont hide

My code currently, in ----------- ------------ areas i need to just add that code
VBA Code:
Option Explicit

Public Sub CustomPrint()
  Dim lPrint As Long
    Dim Ans As Variant
    Dim myValue1 As Variant
    Dim myValue2 As Variant
        
        
        
         Ans = MsgBox("  Can I Print The Pages        ", vbYesNo)
        
    Select Case Ans
    Case vbYes
        myValue1 = InputBox("Starting Inspection List Number") 'Input box stating the starting inspection page number
        myValue2 = InputBox("Ending Inspection List Number")    'Input box stating the ending inspection page number
        
        For lPrint = myValue1 To myValue2 'Specify the number of items to print from cells A3-XXXXXXX
 
        [A3] = Sheet9.[$I2].Offset(lPrint - 0, 0) '[A3} starting cell of 1 as mentioned above, is the cell value to change every time on the ActiveSheet, Set the cell value to change in [__]
                                            'Range from Sheet number, cell range in second [__], Offset is the starting row and column
'--------------------------------------




'Please someone assist to loop through each row checking column J-M if there is an "X" in the cell then it must hide a specific range of rows on sheet1 and then loop to next row




'--------------------------------------
        ActiveSheet.PrintOut
        'ActiveSheet.PrintOut Preview:=True
        Next lPrint
        'Do something such as run whatever code or call a macro
      
    Case vbNo
    Exit Sub
    End Select
 


End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,214,805
Messages
6,121,665
Members
449,045
Latest member
Marcus05

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