+ Reply to Thread
Results 1 to 6 of 6

Using VBA to print a dynamic range.

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Using VBA to print a dynamic range.

    Dear All,
    I am using the following code to select a defined dynamic range and to print it.
    As written here it fails with an error message saying that the method is not supported.
    Please Login or Register  to view this content.
    The code was arrived at by running a macro and changing the range details. If I run it as a macro it works.
    If I change the code to:-
    Please Login or Register  to view this content.
    It fails again as above.
    Where am I going wrong?
    John

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Using VBA to print a dynamic range.

    The PrintArea property is a string, not a range, so

    Please Login or Register  to view this content.
    or just

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Using VBA to print a dynamic range.

    shg,
    Thanks for your interest.
    I have tried
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    Both give Error "application or object defined error"
    So I still don't quite understand.
    John

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Using VBA to print a dynamic range.

    In your first example, you have a With statement that doesn't do anything. Activesheet (obviously) and Range refer to the active sheet, not to Worksheets("Envelope_List"). You might instead use

    Please Login or Register  to view this content.
    I don't understand why the second example doesn't work for you. Is the range name valid?

  5. #5
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Using VBA to print a dynamic range.

    shg
    I am still in difficulty, with all your suggestions giving the application or object defined error. I am sure that the worksheet and range names are as stated. The range was defined as dynamic in the name manager using a formula like = Offset(Sheet1!($A$10,0,0,Counta(Sheet1!$A:$A),Counta(Sheet1!$5:$5)).
    The code is driven by a button click event.
    If you can think of anything else It would be very helpful.
    regards
    John

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Using VBA to print a dynamic range.

    Post a workbook that minimally illustrates the problem.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1