slayer1957
Board Regular
- Joined
- Jan 9, 2017
- Messages
- 50
Good day,
I have to print checklists for multiple equipment, the heading and some data changes with every print as per code currently below.
The problem i have is that i have multiple worksheets and every time i need to change the sheet number hoping i made to correct selection to print the checklist.
I need to add just a combo box or an array of selection to change the variable that i do not need to go in visual basic editor each time to print from that sheet.
So just to add, i have an index worksheet, all worksheet names is in A1-A10 (example, apples, oranges, banana). The combo box must popup and let me make the selection between apples, oranges, bananas and then print the checklist according to the rows i select in my current code
From the code i have to manually change sheet 6 the whole time where i can just make the selection from a combobox or array and then it prints everytime from that. Please assist
I have to print checklists for multiple equipment, the heading and some data changes with every print as per code currently below.
The problem i have is that i have multiple worksheets and every time i need to change the sheet number hoping i made to correct selection to print the checklist.
I need to add just a combo box or an array of selection to change the variable that i do not need to go in visual basic editor each time to print from that sheet.
So just to add, i have an index worksheet, all worksheet names is in A1-A10 (example, apples, oranges, banana). The combo box must popup and let me make the selection between apples, oranges, bananas and then print the checklist according to the rows i select in my current code
VBA Code:
Public Sub CustomPrint()
Dim lPrint As Long
'------------------------------------------------------------
'START ROW SELECTION TO PRINT
Dim UserInput1 As String, X
UserInput1 = InputBox("Please enter START rows that you would like to print")
If UserInput1 = "" Then Exit Sub
X = UserInput1
'END ROW SELECTION TO PRINT
Dim UserInput2 As String, Y
UserInput2 = InputBox("Please enter END rows that you would like to print")
If UserInput2 = "" Then Exit Sub
Y = UserInput2
'------------------------------------------------------------
For lPrint = X To Y
[A3] = Sheet6.[$I2].Offset(lPrint - 0, 0) '[A3} 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
[A4] = Sheet6.[$J2].Offset(lPrint - 0, 0)
[B4] = Sheet6.[$D2].Offset(lPrint - 0, 0)
[E4] = Sheet6.[$G2].Offset(lPrint - 0, 0)
ActiveSheet.PrintOut
'ActiveSheet.PrintOut Preview:=True
Next lPrint
End Sub
From the code i have to manually change sheet 6 the whole time where i can just make the selection from a combobox or array and then it prints everytime from that. Please assist