Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. Option Explicit
  2.  
  3. LastRowRoutes = VV 'LastRowRoutes & VV are Variant
  4. Dim M As Variant
  5. Dim arr() As Variant
  6. Dim cnt As Variant
  7. Dim strFilename As String, strFilepath As String
  8. Dim wksSheet1 As Worksheet
  9. Dim printSheets As Variant
  10. printSheets = arr
  11.  
  12.  
  13. Set wksSheet1 = ThisWorkbook.sheets("Sheet1")
  14. Set wksSheet1 = Worksheets("Sheet1")
  15. strFilepath = "E:"
  16.  
  17. With wksSheet1
  18. strFilename = strFilepath & "TripSheets_Print.pdf"
  19. End With
  20.  
  21. cnt = 0
  22. For M = 22 To LastRowRoutes
  23. If Worksheets(M).Range("B4").Value <> "" Then
  24. ReDim Preserve arr(0 To cnt)
  25. arr(cnt) = Worksheets(M).Range("A1:K43")
  26. cnt = cnt + 1
  27. Else
  28. End If
  29. Next
  30.  
  31. ThisWorkbook.sheets(printSheets).Select '*Type Mismatch here
  32.  
  33.  
  34. wksSheet1.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFilename, Quality:=xlQualityStandard, _
  35. IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
  36.  
  37. '@@@@@@@@ code below to view array contents in lieu of select & export
  38.  
  39. For M = LBound(arr) To UBound(arr) 'type mismatch here as well
  40. msg = msg & arr(M) & vbNewLine
  41. Next M
  42. MsgBox "the values of my array are: " & vbNewLine & msg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement