+ Reply to Thread
Results 1 to 6 of 6

how to print my collection to the immediate window

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    how to print my collection to the immediate window

    doing something wrong as the last for next loop errors out. can someone tell me what i am doing wrong?

    Please Login or Register  to view this content.
    it errors out on the print statement

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: how to print my collection to the immediate window

    What are you expecting it to print? Currently you've told it to print an object, which won't work. It's also generally better to use a For Each loop with a collection.
    Rory

  3. #3
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to print my collection to the immediate window

    thanks @rorya

    yup, i see that now. so i changed the code to this:

    Please Login or Register  to view this content.
    but now its printing the same Name 312 times, can you tell me why?

  4. #4
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: how to print my collection to the immediate window

    so i changed the for next loop to a for each loop like so, but still getting the same name printed 312 times

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-11-2018
    Location
    Gurgaon
    MS-Off Ver
    XP
    Posts
    10

    Re: how to print my collection to the immediate window

    Quote Originally Posted by rorya View Post
    What are you expecting it to print? Currently you've told it to print an object, which won't work. It's also generally better to use a For Each loop with a collection.
    Thanks rorya for clearing the doubt.

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,908

    Re: how to print my collection to the immediate window

    You're adding the same object each time.

    First off, never use Dim ... As New ...

    Dim the variable normally, then use:

    Please Login or Register  to view this content.
    inside your loop, so that you create a new instance each time, and add that to the collection.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Open Print Window
    By dougman824 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2017, 10:19 AM
  2. Cell height difference in normal and print preview window
    By melvinkoshy in forum Excel General
    Replies: 1
    Last Post: 04-08-2016, 07:34 AM
  3. Replies: 4
    Last Post: 10-30-2015, 01:30 PM
  4. [SOLVED] Performance of iteration through Words collection degrades as collection gets bigger
    By 6StringJazzer in forum Word Programming / VBA / Macros
    Replies: 7
    Last Post: 01-14-2014, 09:44 AM
  5. Replies: 2
    Last Post: 12-23-2011, 11:04 AM
  6. Replies: 1
    Last Post: 10-27-2005, 06:00 PM
  7. Set print area with code - about to throw PC through the window!
    By weaholt in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2005, 10:05 AM

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