Change a cells data then Print based on print area pages?

Saltioh

New Member
Joined
May 5, 2022
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hey Guys,

Not sure how to word my question, I'm trying to make a stillage sheet for a sheet metal company, I'm trying to get it so the sheet will insert the stillage number into a cell, then print the first page of the print area, then change the same cell as the original to the next stillage's number, then print the 2nd page of the print area. I can provide some image examples if required.

Thanks in advance
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hello Saltioh, welcome to us.
Hope so you are know something about VBA, because it will be needed.
If I understand you want every time you change value in the some cell ("A1" in this case) automaticaly print this page.
If I'm right you can try in this way.
Open VBA editor and in the sheet module insert this code.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    vFromN = ActiveSheet.Range("A1").Value
    vToN = vFromN
    If IsNumeric(vFromN) And vFromN > 0 And _
        Not vFromN > ActiveSheet.PageSetup.Pages.Count Then _
        ActiveWindow.SelectedSheets.PrintOut _
        vFromN, vToN, 1, True, , , True, , False

End Sub
 
Upvote 0
Hey, thanks for the response.

This looks very close to what I trying to achieve, Is there a way that this code can, for example, Cell A1 has "1", then print page 1, then change the data itself in Cell A1 to 2, then print page 2? and so on, the numbers it prints be from a list? eg, 1, 2, 3, 6, 14, P.

Is there a way to have P represent a Page number?

Sorry if this seems overly complicated.
 
Upvote 0
Seems not complicated, but where will be list with pages for printing stored?
 
Upvote 0
Where would be the best place? Can it be within the Code? Or Is it best they are held within the worksheet somewhere? in cells perhaps?
 
Upvote 0
Yes, the pages can be stored in the currently excel file, if they will be always same numbers.
If you want to change pages numbers, they can taken from worksheet cells.
 
Upvote 0
Fantastic, How would I adapt your original code to do that?

Thank you so much for your help.
 
Upvote 0
The better solution will be to have command button to do job.
Do to Developer tab and insert button. Set button to run this code.
VBA Code:
Sub PrintPages()

    Dim vPages, vPage, vN As Integer
   
    With ActiveSheet.Range("A1")
        vPages = Split(.Value, "/")
        For vN = 0 To UBound(vPages)
            If IsNumeric(Trim(vPages(vN))) Then
                vPage = CInt(Trim(vPages(vN)))
                If vPage > 0 And Not vPage > _
                    ActiveSheet.PageSetup.Pages.Count Then _
                    ActiveWindow.SelectedSheets.PrintOut _
                    vPage, vPage, 1, True, , , True, , False
            End If
        Next vN
    End With
    
End Sub
In the cell "A1" input number of the pages, splited by slash("2/3/5" for example),
that you want to print and run command button.
To avoid mistakes take care the values entered are correct format.
When you finish testing replace this part of code...
VBA Code:
ActiveSheet.PageSetup.Pages.Count Then _
ActiveWindow.SelectedSheets.PrintOut _
vPage, vPage, 1, True, , , True, , False
with this...
VBA Code:
ActiveSheet.PageSetup.Pages.Count Then _
ActiveWindow.SelectedSheets.PrintOut _
vPage, vPage, 1, False, , , True, , False
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

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