Excel VBA script to print sheets based on cell values

AM30146

New Member
Joined
Jul 9, 2018
Messages
2
New to this forum and a rookie at Excel VBA.

I have a spreadsheet that I am trying to use to scan in a varietyof parts into the spreadsheet, sheet 1.
Then on a separate sheet, sheet2, I am searching the Tablerow 1 from sheet 1 for a particular part number. Then based on that part numberI am copying the parts serial number from row 2 of sheet 1 to this sheet 2 (thisis done based on a formula written in each cell on that sheet.)
Then I have a VBA script written to print off specificsheets based on a particular cell not being blank. Basically, when I get sixparts serial numbers on a page I then print that page.
I have tested this same code on another basic spreadsheetand it worked well. However, on this spreadsheet I cannot get it to work and amat my wits end.
I would be willing to share the file if anyone would bewilling to help me figure out why this isn’t working.
Thanks,
AM30146
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Here is code I entered into two separate worksheets:

Sheet 1 – VBA Code
*Private SubWorksheet_Change(ByVal Target As Range)

*DimxCellColumn As Integer
*DimxTimeColumn As Integer
*Dim xRow,xCol As Integer

*xCellColumn= 1
*xTimeColumn= 4
*xRow =Target.Row
*xCol =Target.Column
*IfTarget.Text <> "" Then
*If xCol = xCellColumn Then
*Cells(xRow, xTimeColumn) = Now()
*End If
*End If

*End Sub

Sheet2 – VBA code
*Private SubWorksheet_Change(ByVal Target As Range)
*Dim KeyCells As Range
*Dim A7 As String
*Dim A13 As String
*Dim A19 As String

*A7 = Range("B7").Value
*A13 = Range("B13").Value
*A19 = Range("B19").Value

*Set KeyCells = Range("B7")
*If Not Application.Intersect(KeyCells,Range(Target.Address)) Is Nothing Then
*Select Case A7
*Case 1
*Worksheets("17-20469-000").PrintOutfrom:=1, to:=1
*End Select
*End If

*Set KeyCells = Range("B13")
*IfNot Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
*Worksheets("17-20469-000").Activate
*Select Case A13
*Case 2
*Worksheets("17-20469-000").PrintOutfrom:=2, to:=2
*End Select
*End If

*Set KeyCells = Range("B19")
*If Not Application.Intersect(KeyCells,Range(Target.Address)) Is Nothing Then
*Select Case A19
*Case 3
*Worksheets("17-20469-000").PrintOutfrom:=3, to:=3
*End Select
*End If
*Set KeyCells = Range("B7")

*End Sub
 
Upvote 0

Forum statistics

Threads
1,223,901
Messages
6,175,277
Members
452,629
Latest member
SahilPolekar

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