Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7578055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:20:26+00:00 2026-05-30T17:20:26+00:00

I have a task to return all the consecutive rows in a particular column.

  • 0

I have a task to return all the consecutive rows in a particular column. They will all have data consecutively and the first blank row will signal the end of the data. I used this to find the column and pass that over to my range, but I keep getting syntax errors.

Dim Col
Dim found As Boolean
Dim cellRange As Range

    found = Cells.Find(What:="My_Search_Text", After:=ActiveCell, LookIn:=xlValues, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

    'Take that column as the range.
    If (found) Then
        Col = ActiveCell.Column
        cellRange = ActiveSheet.Range(Col, ActiveSheet.Range(Col).End(xlDown)).Select

The goal here is to get the correct range of cells and loop through them, however, I’m not at the loop part as the last line is the one that doesn’t work at all.

So what is the correct syntax for this last line and is there a better way to accomplish what I’m trying to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:20:27+00:00Added an answer on May 30, 2026 at 5:20 pm

    Try the following which I have tested with a selection of situations.

    I have included notes about the changes I have made but come back with questions if anything is unclear.

    Option Explicit
    Sub FindRange()
    
      Dim RangeStart As Range
      Dim RangeEndPlusOne As Range
      Dim RangeEntire As Range
    
      ' Better to explicitly identify the sheet being searched
      With Sheets("Source")
        ' Do not attempt to activate the target cell.  Instead get it as a range.
        ' Are you sure about "LookAt:=xlPart"?  "LookAt:=xlWhole" might be better
        ' I have explicitly started the search from cell A1 rather than the current
        ' position of the cursor.
        Set RangeStart = .Cells.Find(What:="My_Search_Text", After:=.Range("A1"), _
                                    LookIn:=xlValues, LookAt:=xlPart, _
                                    SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                                    MatchCase:=False, SearchFormat:=False)
    
        If RangeStart Is Nothing Then
          ' My "My_Search_Text" not found
        Else
          ' If the cell below RangeStart is empty, End(xlDown) will jump to
          ' the bottom of the column or the next cell in the column with a value.
          ' Search down the column for an empty cell
          Set RangeEndPlusOne = .Columns(RangeStart.Column).Find(What:="", _
                                 After:=RangeStart, _
                                 LookIn:=xlValues, LookAt:=xlWhole, _
                                 SearchOrder:=xlByRows, SearchDirection:=xlNext, _
                                 MatchCase:=False, SearchFormat:=False)
          ' I ought to test for not found but I assume there is a blank cell below
          ' RangeStart
    
          Set RangeEntire = .Range(RangeStart, RangeEndPlusOne.Offset(-1, 0))
    
          Debug.Print "Start  " & RangeStart.Address
          Debug.Print "End+1  " & RangeEndPlusOne.Address
          Debug.Print "Entire " & RangeEntire.Address
        End If
    
      End With
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following task: Query SOLR and return a weighted list based on
I have a service component (common task for all my apps), which can be
Possible Duplicate: Finding all cycles in graph I have a task I've been wrapping
I have a method where i want to return Task and the task finish
I have 500 connected clients on the server. Server sends data to all clients
I have a custom MSBuild task, which processes a set of files and returns
I am new this sharepoint development and i have task in hand to do
I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end
I have a task and I want to generate some code using the CodeDom.
I have a Task object that has a collection of Label objects ... in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.