Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    San Clemente, California, USA
    Posts
    130
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Looping Help (Excel 97)

    Hello...

    I am sitting here with all my VBA books in front of me but can't find the exact thing I am looking for!

    I want to write the following in VBA:

    Cell B4 = Cell R6
    Print Active Worksheet

    Then I want cell B4 to equal R7 and so on until it hits an empty cell and exits the routine.

    Thank you!

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Looping Help (Excel 97)

    What is the "so on" part, are you going down a column? If so, what should B5 be set to?

    Generically, you want to use

    Range(B4).Value = Range(R6).Value

    but without knowing how the entire "so on" works, it's hard to assist further.
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    San Clemente, California, USA
    Posts
    130
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Looping Help (Excel 97)

    Sorry I should have been more specific, I forget you guys can't read my mind!

    I want to do the following
    B4=R7
    Print
    B4=R8
    Print
    B4=R9
    Print

    I want to do this unit I hit a blank cell in Column R.

    Thanks!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Looping Help (Excel 97)

    Try this:

    Dim lngRow As Long
    lngRow = 6

    ' Loop through cells in column 18 (=column R)
    Do While Cells(lngRow, 18) <> ""
    ' Set value of B4 to that in "current" row in column 18
    Cells(4, 2) = Cells(lngRow, 18)
    ' Print active sheet
    ActiveSheet.Print
    ' On to next row
    lngRow = lngRow + 1
    Loop

  5. #5
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    San Clemente, California, USA
    Posts
    130
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Looping Help (Excel 97)

    Problem Solved!

    Thank you very much and I will keep this for future reference!

    Thanks!

Posting Permissions

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