ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   MACRO: Catching only filled cell data (https://www.excelbanter.com/excel-discussion-misc-queries/119992-macro-catching-only-filled-cell-data.html)

sumit

MACRO: Catching only filled cell data
 
I want to have a macro to select the cells with only filled data . I
have tried with the dollar sign to select the entire sheet but it does
not work. just give in options

Thankue


Gary''s Student

MACRO: Catching only filled cell data
 
Sub nonempty()
Dim rr As Range, r2 As Range, r3 As Range
Dim r4 As Range
Set r2 = ActiveSheet.UsedRange
Set r3 = ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlank s)
For Each rr In r2
If Intersect(rr, r3) Is Nothing Then
If r4 Is Nothing Then
Set r4 = rr
Else
Set r4 = Union(r4, rr)
End If
End If
Next
r4.Select
End Sub

But it wil not select cells that have only comments in them.
--
Gary's Student


"sumit" wrote:

I want to have a macro to select the cells with only filled data . I
have tried with the dollar sign to select the entire sheet but it does
not work. just give in options

Thankue




All times are GMT +1. The time now is 03:50 AM.

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