slayer1957
Board Regular
- Joined
- Jan 9, 2017
- Messages
- 50
Good day,
I have code that prints checklists of equipment with a loop function.
I want to improve on this, the checklist usually print, changing cell A3 each time with a value in Sheet9 cell $I as the heading.
I now want to include a table with options of equipment in columns J-W on Sheet9, if i mark the cell with an "X" it must unhide certain rows which i will specify as range on Sheet1. If there is no "X" the rows must remain hidden.
So if lets say there is an "X" in row J,K,L,M and none in N-W on sheet9, it must unhide specified rows range in sheet1 according to J,K,L,M and rows specified for N-W must remain hidden. Then it must print the first checklist.
Then it will check next row for "X" and hide/unhide according to "X" and print again.
I have some code for the printing which i usually use and started the one for the X but i dont know how to offset each row the whole time as each row is checked for an "X"
Can someone help, can you also explain the offset function with a comment maybe
I have code that prints checklists of equipment with a loop function.
I want to improve on this, the checklist usually print, changing cell A3 each time with a value in Sheet9 cell $I as the heading.
I now want to include a table with options of equipment in columns J-W on Sheet9, if i mark the cell with an "X" it must unhide certain rows which i will specify as range on Sheet1. If there is no "X" the rows must remain hidden.
So if lets say there is an "X" in row J,K,L,M and none in N-W on sheet9, it must unhide specified rows range in sheet1 according to J,K,L,M and rows specified for N-W must remain hidden. Then it must print the first checklist.
Then it will check next row for "X" and hide/unhide according to "X" and print again.
I have some code for the printing which i usually use and started the one for the X but i dont know how to offset each row the whole time as each row is checked for an "X"
Can someone help, can you also explain the offset function with a comment maybe
VBA Code:
Option Explicit
Public Sub CustomPrintBASED_ON_SELECTION()
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
If Sheet9.Range("J3").Value = "X" Then 'this portion must also check all cells for an X in the entire row and hide unhide accordingly
Rows("51:60").EntireRow.Hidden = True
ElseIf Sheet9.Range("E50").Value = "" Then
Rows("51:60").EntireRow.Hidden = False
End If
If Sheet9.Range("K3").Value = "X" Then 'this cell
Rows("51:60").EntireRow.Hidden = True
ElseIf Sheet9.Range("E50").Value = "" Then
Rows("51:60").EntireRow.Hidden = False
End If
If Sheet9.Range("L3").Value = "X" Then 'etc
Rows("51:60").EntireRow.Hidden = True
ElseIf Sheet9.Range("E50").Value = "" Then
Rows("51:60").EntireRow.Hidden = False
End If
ActiveSheet.PrintOut
'ActiveSheet.PrintOut Preview:=True
Next lPrint
Case vbNo
Exit Sub
End Select
End Sub