ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Searching 1 column for data (https://www.excelbanter.com/excel-programming/332516-searching-1-column-data.html)

Oreg[_29_]

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


--
Oreg
------------------------------------------------------------------------
Oreg's Profile: http://www.excelforum.com/member.php...fo&userid=9195
View this thread: http://www.excelforum.com/showthread...hreadid=381181


mangesh_yadav[_355_]

Searching 1 column for data
 

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


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=381181


Ed Ferrero[_5_]

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




Oreg[_30_]

Searching 1 column for data
 

Mangesh & Ed,

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

Ore

--
Ore
-----------------------------------------------------------------------
Oreg's Profile: http://www.excelforum.com/member.php...nfo&userid=919
View this thread: http://www.excelforum.com/showthread.php?threadid=38118



All times are GMT +1. The time now is 10:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com