+ Reply to Thread
Results 1 to 6 of 6

How to select general (unspecified) range that is active ?

  1. #1
    Registered User
    Join Date
    02-07-2013
    Location
    Slovakia
    MS-Off Ver
    Excel 2010
    Posts
    31

    How to select general (unspecified) range that is active ?

    Hello to everyone, how are you today ? I am little bit sad (or mad) because I am stuck at relatively easy task (but not for me now as I discovered) and cant find nothing useful on net , so please help:D

    I have this macro for searching text in whole column and then add answer to next column - row. The problem is that the search range is only for specific column (now only for C1 to its end), but I want to search the text for any active column that I will select. So I need to know how to define, that the range will be dynamic or general for all columns that I select to search in, not only column C or some other. Hope I explain it clear.

    Please Login or Register  to view this content.
    Last edited by arlu1201; 02-08-2013 at 08:49 AM. Reason: Use code tags in future

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,705

    Re: How to select general (unspecified) range that is active ?

    Replace this:

    Please Login or Register  to view this content.
    with this

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    02-07-2013
    Location
    Slovakia
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: How to select general (unspecified) range that is active ?

    Hi thanks for your quick reply, but its not working after I change it. I get Run time error "1004". My question is still how to define a general range of one whole column without using the letter of it. I think that can solve the problem. It should look something like this, (but the question-mark will be replaced with some symbol or sign) to make it sense to VBA:

    Range(ActiveSheet.Range("?"), ActiveSheet.Range("?").End(xlUp)).Cells

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644
    To get the whole column for the active cell use ActiveCell.EntireColumn.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    02-07-2013
    Location
    Slovakia
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: How to select general (unspecified) range that is active ?

    Ok I will try it, hope it will work
    Last edited by Sachy; 02-08-2013 at 11:30 AM.

  6. #6
    Registered User
    Join Date
    02-07-2013
    Location
    Slovakia
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: How to select general (unspecified) range that is active ?

    Yes, I finally have it ! I change the code to this to get it to work:

    For Each FindCell In Range(ActiveCell.EntireColumn, ActiveCell.EntireColumn.End(xlUp)).Cells

    But then when I want to use it to find more words at the same time I get an error. Likely a friend of mine adjust it to work with more word. The code looks like this:

    Public Sub findWord()


    Dim findString As String
    Dim myReplace As String
    Dim findCell As Range

    findString = "Need to be added to SESDR"
    myReplace = "Add to SESDR"
    Set findRange = Selection

    If findString = "" Then Exit Sub

    For Each cell a In findRange
    If InStr(cell, findString) > 0 Then cell.Offset(0, 1) = myReplace
    Next cell
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1