Consulting

Results 1 to 2 of 2

Thread: Solved: looping between named ranges

  1. #1
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location

    Solved: looping between named ranges

    Hi,

    I have a spreadsheet where cells i.e. A13, A25, A28 and A38 are named ranges (inflowstart, inflowend, outflowstart, outflowend)

    I want to run a loop that looks between rows 13 and 25 and puts formulae in adjacent cells i.e B13 D13 etc

    How do I run a loop that says if the row is between inflowstart and inflowend do something in the adjacent cells and then between outflowstart and outflowend put a different number in the adjacent cells

    The issue is that the number or rows between inflowstart, unflowend, outflowstart and outflowend changes depending on the volume or items for that day, so the ranges are never always A13 etc

    At the end of the days work I want to run a macro that deletes the rows between the ranges. How can I do this also

    Thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub philfer()
    Dim i As Long

    With ActiveSheet

    For i = .Range("inflowstart").Row To .Range("outflowend").Row

    'your code - i points to the row
    Next i

    .Range("inflowstart").Resize(.Range("outflowend").Row - _
    .Range("inflowstart").Row + 1).EntireRow.Delete
    End With

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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