+ Reply to Thread
Results 1 to 4 of 4

Searching 1 column for data

  1. #1
    Registered User
    Join Date
    05-06-2004
    Posts
    60

    Searching 1 column for data

    Hello,

    I would like to create a macro to search Column A for any entries & if there is no data in Column A, insert the words "No Data" into Cell A2. If there is data, then sort the data descending. I can sort the data, but am not sure how to search the column ??

    Thanks,

    Oreg

  2. #2
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Something like this probably:

    If WorksheetFunction.CountA(Range("A:A")) = 0 Then
    Range("A2") = "No Data"
    Else
    Columns("A:A").Select
    Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    End If


    Mangesh

  3. #3
    Ed Ferrero
    Guest

    Re: Searching 1 column for data

    Hi Oreg,

    Set rng = Worksheets("Sheet1").Range("A:A")
    If WorksheetFunction.CountA(rng) = 0 Then
    ' no data in column A
    Worksheets("Sheet1").Range("A2") = "No Data"
    End If

    Ed Ferrero
    http://edferrero.m6.net

    > I would like to create a macro to search Column A for any entries & if
    > there is no data in Column A, insert the words "No Data" into Cell A2.
    > If there is data, then sort the data descending. I can sort the data,
    > but am not sure how to search the column ??
    >
    > Thanks,
    >
    > Oreg




  4. #4
    Registered User
    Join Date
    05-06-2004
    Posts
    60
    Mangesh & Ed,

    Thanks for the responses....that's just what I needed !!

    Oreg

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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