Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I am trying to use VBA to creat a dynamic print range. What I have doesn't seem to be working. Will someone be kind enough to have a look at what I have and share with me where I have went wrong and a possible solution? The line in red is giving me a "Type mismatch error"
Rich (BB code):
Sub printme_d()
dim rwtopLeft as Long, coltopLeft as Long
dim rwbtmRight as ong, colbtmRight as Long
dim diarng as range
Stop
rwtopLeft = Application.WorksheetFunction.VLookup("D", ws_lists.Range("X3:AD10"), 3, False)
coltopLeft = Application.WorksheetFunction.VLookup("D", ws_lists.Range("X3:AD10"), 4, False)
rwbtmRight = Application.WorksheetFunction.VLookup("D", ws_lists.Range("X3:AD10"), 5, False)
colbtmRight = Application.WorksheetFunction.VLookup("D", ws_lists.Range("X3:AD10"), 6, False) + 26
Set diarng = ws_front.Range(ws_front.Cells(rwtopLeft, coltopLeft), ws_front.Cells(rwbtmRight, colbtmRight))
With ws_front.PageSetup
ws_front.Unprotect
.PrintArea = diarng
pgnums = .Pages.Count
ws_front.Protect
End With
. . .