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
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