Results 1 to 6 of 6

Thread: [RESOLVED] For each record loop? - VBA

  1. #1

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342

    Resolved [RESOLVED] For each record loop? - VBA

    Disclaimer - Newer to VBA.

    I have a sheet I want to print out, for each record in a range.

    In the range, I have the following data:

    Apple
    Grape
    Pear
    Apricot

    The price breaks are based on information in columns 2 - 4 of the range.

    I have a seperate window, which is all formated pretty like. What I want to do is enter Apple in the top cell (programatically) and print the page, then change Apple to Grape, and print the page again.

    I am trying to do something like a For each, Do Loop....but am not having any luck....any ideas ?
    Talk does not cook rice.
    -Chinese Proverb

  2. #2
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: For each record loop? - VBA

    This is Excel? When you say a "separate window", do you mean that you have 2 Excel workbooks open and you want to take the fruity data from a sheet in one workbook and programmatically use that to operate on a sheet in the second workbook?
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  3. #3
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: For each record loop? - VBA

    Try the following

    VB Code:
    1. Sub loop_example()
    2.     Dim MyRange As Range
    3.     Dim MyCell As Range
    4.    
    5.     Set MyRange = 'Insert your range here
    6.    
    7.     For Each MyCell In MyRange.Columns(1).Cells
    8.         MsgBox MyCell.Value
    9.     Next MyCell
    10. End Sub

  4. #4

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342

    Re: For each record loop? - VBA

    DKenny!
    You Rock! Works Great!

    Sorry, webtest...I should have been clearer...different worksheet...only one instance of Excel is running....

    The printer is going wild !!
    Talk does not cook rice.
    -Chinese Proverb

  5. #5
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: [RESOLVED] For each record loop? - VBA

    "The printer is going wild !!"
    Post your code.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  6. #6

    Thread Starter
    Hyperactive Member VB4fun's Avatar
    Join Date
    May 2003
    Location
    too far from Fiji
    Posts
    342

    Re: [RESOLVED] For each record loop? - VBA

    That is a good thing.

    I have a hundred or so items, and it is changing the item and printing the page, changing the item and printing the page.....

    all I have to do is press one button!

    This is great!
    Talk does not cook rice.
    -Chinese Proverb

Posting Permissions

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



Click Here to Expand Forum to Full Width