Results 1 to 4 of 4

Thread: VBA Code not working when inserted with another code.

  1. #1
    Seeker EmilVictor's Avatar
    Join Date
    Oct 2018
    Posts
    5
    Articles
    0
    Excel Version
    2012

    VBA Code not working when inserted with another code.



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Application.ScreenUpdating = False
    Dim copySheet As Worksheet
    Dim pasteSheet As Worksheet
    Set copySheet = Worksheets("Monthly Generic Rebate")
    Set pasteSheet = Worksheets("Trend")
    copySheet.Range("W2:z2").Copy
    pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    ChDir "C:\Users\emilvictor.masa\Desktop"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Emil, OpenAfterPublish:=True


    but when I am printing it. it seems that the active spreadsheet is not printing.

    only 1 sheet.

  2. #2
    Conjurer alansidman's Avatar
    Join Date
    Oct 2018
    Location
    Steamboat Springs
    Posts
    193
    Articles
    0
    Excel Version
    2019
    Instead of ActiveSheet, why not use the variable name of the sheet you want printed.

  3. #3
    Seeker EmilVictor's Avatar
    Join Date
    Oct 2018
    Posts
    5
    Articles
    0
    Excel Version
    2012
    ok I have normal sheet.

    Sheet1 Sheet2 Sheet 3 Sheet 4 Sheet 5

    would you be able to code for me?

    thanks,

  4. #4
    Conjurer alansidman's Avatar
    Join Date
    Oct 2018
    Location
    Steamboat Springs
    Posts
    193
    Articles
    0
    Excel Version
    2019
    You have copySheet andd pasteSheet as variables. Which one do you want printed. That is the one you need to place instead of ActiveSheet.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •