Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DZ DZ is offline
external usenet poster
 
Posts: 29
Default Selectblank cells

Hi

I want to select blank cells programatically. I used the following code. I
actually tries two different range objects.

The problem is that, not all of the blank cells inside the used range get
selected. I clicked on some of the blank cells that did not get selected and
they were definitely blank. Does anyone know why some of the blank cells
don't get selected.

Thanks


Sub HighligteCells()

Dim rg As Range
Set rg = RealUsedRange

'ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlan ks).Select

rg.SpecialCells(xlCellTypeBlanks).Select


End Sub




Public Function RealUsedRange() As Range

Dim FirstRow As Long
Dim LastRow As Long
Dim FirstColumn As Integer
Dim LastColumn As Integer

On Error Resume Next

FirstRow = Cells.Find(What:="*", After:=Range("IV65536"),
LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Row

FirstColumn = Cells.Find(What:="*", After:=Range("IV65536"),
LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext).Column

LastRow = Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues,
LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

LastColumn = Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues,
LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column

Set RealUsedRange = Range(Cells(FirstRow, FirstColumn), Cells(LastRow,
LastColumn))

On Error GoTo 0

End Function

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Selectblank cells

On Aug 15, 10:06*am, DZ wrote:
Hi

I want to select blank *cells programatically. I used the following code. I
actually tries two different range objects.

The problem is that, not all of the blank cells inside the used range get
selected. I clicked on some of the blank cells that did not get selected and
they were definitely blank. Does anyone know why some of the blank cells
don't get selected.

Thanks

Sub HighligteCells()

Dim rg As Range
Set rg = RealUsedRange

'ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlan ks).Select

*rg.SpecialCells(xlCellTypeBlanks).Select

End Sub

Public Function RealUsedRange() As Range

* * Dim FirstRow * * * *As Long
* * Dim LastRow * * * * As Long
* * Dim FirstColumn * * As Integer
* * Dim LastColumn * * *As Integer

* * On Error Resume Next

* * FirstRow = Cells.Find(What:="*", After:=Range("IV65536"),
LookIn:=xlValues, LookAt:= _
* * xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Row

* * FirstColumn = Cells.Find(What:="*", After:=Range("IV65536"),
LookIn:=xlValues, LookAt:= _
* * xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext).Column

* * LastRow = Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues,
LookAt:= _
* * xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

* * LastColumn = Cells.Find(What:="*", After:=Range("A1"), LookIn:=xlValues,
LookAt:= _
* * xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column

* * Set RealUsedRange = Range(Cells(FirstRow, FirstColumn), Cells(LastRow,
LastColumn))

* * On Error GoTo 0

End Function


Hi,

I have encountered this many times before but cannot remember how to
duplicate it, a workaround that works for me is to do a find and
replace, so find all "" cells and replace them with a character then
do the opposite something along the lines of...

ActiveSheet.UsedRange.Replace "", "^-^", xlWhole
ActiveSheet.UsedRange.Replace "^-^", "", xlWhole

James
  #3   Report Post  
Posted to microsoft.public.excel.programming
DZ DZ is offline
external usenet poster
 
Posts: 29
Default Selectblank cells

Yes It worked

Thank you
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
Excel: match two cells in one sheet to two cells in another and return a third cells value Spence Excel Worksheet Functions 3 February 13th 11 05:33 AM
compare 2 column cells and return the adjacent columns cells data of the cell trebor57 Excel Worksheet Functions 1 February 1st 11 02:54 PM
join data in multiple cells when adjoining cells match criteria ?? angiec50 Excel Worksheet Functions 1 October 6th 09 10:27 AM
Number Cells skip blank cells, Excel 2000 & 2003 jfcby[_2_] Excel Programming 4 July 31st 07 03:02 PM
Skip cells with TAB/SHIFT+TAB but allow arrow keys/mouse selection of skipped cells Wescotte Excel Programming 1 June 6th 05 07:00 PM


All times are GMT +1. The time now is 12:38 PM.

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

About Us

"It's about Microsoft Excel"