Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2009
    Posts
    204

    Unanswered: Name a variable that contains a loop in vba

    Hello,

    What I want is to select a range from A5 to the cell above the one that says "( Blank )".

    I thought to write a loop that looks for blank then move one cell up, anme that as a variable, then use that variable in a range.

    Apparently, I'm doing something wrong.

    Can somebody please help me with this?

    Code:
    Sub Macro1()
    
    Dim last As Range
    
    last = Range("A5").Select
    Do Until ActiveCell = "( Blank )"
    ActiveCell.Offset(1, 0).Select
    Loop
    ActiveCell.Offset(-1, 0).Select
    
    
    Range("A5", last).Select
    
    End Sub

  2. #2
    Join Date
    Oct 2009
    Posts
    204
    Never mind, this was so unbelievably easy I feel like a moron lol.

    Here was the solution:

    Code:
    Sub Macro1()
    
    Range("A5").Select
    Do Until ActiveCell = "( Blank )"
    ActiveCell.Offset(1, 0).Select
    Loop
    ActiveCell.Offset(-1, 0).Select
    
    Range(ActiveCell, "A5").Select
    
    
    
    End Sub

Posting Permissions

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