Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Select Cells In Column that have data

How do I select cells in column A that have any type of "Data" in them, it
can be numbers, text, or combination. Just need a macro to autoselect
everything in column A that has data.

Thanks

Sean
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Select Cells In Column that have data

You can record it - the actions are
data menu, filter, autofilter
filter on column a to Non Blanks

stop the recorder - macro done!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Select Cells In Column that have data

Hi
Range("A:A").SpecialCells(xlCellTypeConstants, xlNumbers +
xlTextValues).Select

Will select cells with text or numbers. If you want formulas change to
xlTypeFormulas in specialcells. If you want constants and formulas, you
will have to do a set statement

Set ConstCells = Range("A:A").SpecialCells(xlCellTypeConstants,
xlNumbers + xlTextValues)

and same for FormulaCells. Then union the two ranges and select that.

regards
Paul

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Select Cells In Column that have data



--
---
Regards,
Norman



"Sean" wrote in message
...
How do I select cells in column A that have any type of "Data" in them, it
can be numbers, text, or combination. Just need a macro to autoselect
everything in column A that has data.

Thanks

Sean



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Select Cells In Column that have data

Hi Sean,

How do I select cells in column A that have any type of "Data" in them, it
can be numbers, text, or combination. Just need a macro to autoselect
everything in column A that has data.


Try:

'================
Public Sub PopulatedRange()
Dim WB As Workbook
Dim SH As Worksheet
Dim srcRng As Range
Dim destRng As Range
Dim RngA As Range, RngB As Range
Dim popRng As Range

Set WB = Workbooks("Book1.xls") '<<===== CHANGE
Set SH = WB.Sheets("Sheet1") '<<===== CHANGE
Set srcRng = SH.Range("A:A") '<<===== CHANGE

On Error Resume Next
Set RngA = srcRng.Cells. _
SpecialCells(xlCellTypeConstants)
Set RngB = srcRng.Cells. _
SpecialCells(xlCellTypeFormulas)

If Not RngA Is Nothing Then Set popRng = RngA

If Not RngB Is Nothing Then
If Not popRng Is Nothing Then
Set popRng = Union(RngB, popRng)
Else
Set popRng = RngB
End If
End If

popRng.Select

End Sub
'<<================


---
Regards,
Norman


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
How do you select all text/data within all the cells of a column? VisionsIC Excel Discussion (Misc queries) 3 December 20th 08 02:36 AM
How to select certain cells in a column ? Mark246 Excel Discussion (Misc queries) 1 February 25th 08 10:08 PM
Macro to select cells in column enter data then press enter NP New Users to Excel 1 February 20th 08 04:21 PM
Shortcut to select column with data in previous column TJAC Excel Discussion (Misc queries) 1 July 10th 07 06:12 PM


All times are GMT +1. The time now is 07:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"