Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / February 2008

Tip: Looking for answers? Try searching our database.

Finding blank cells

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
teepee - 16 Feb 2008 11:48 GMT
Hello

I want to find the first and second blank cells in a column and return both
their values as variables I can then program with. Anyone know how? I got as
far as:

If ActiveSheet.UsedRange.Count < 2 Then
 MsgBox 1
Else
 MsgBox Columns("A:A").Find(What:="", LookAt:=xlWhole).Row
' Cells.FindNext(After:=ActiveCell).Activate
End If

which returns just the first blank cell but as a messagebox.

Any help much appreciated
Jim Cone - 16 Feb 2008 14:41 GMT
A way that works if there are actually two blank cells...
'--
Sub FirstTwoBlanksOnly()
Dim rOne As Range
Dim rTwo As Range
Dim rng As Range

Set rng = Range("A:A").SpecialCells(xlCellTypeBlanks)
Set rOne = rng.Areas(1)(1)
If rng.Areas(1).Cells.Count > 1 Then
Set rTwo = rng.Areas(1)(2)
Else
Set rTwo = rng.Areas(2)(1)
End If

MsgBox rOne.Address & vbCr & rTwo.Address
End Sub
Signature

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

"teepee"
wrote in message
Hello
I want to find the first and second blank cells in a column and return both
their values as variables I can then program with. Anyone know how? I got as
far as:

If ActiveSheet.UsedRange.Count < 2 Then
 MsgBox 1
Else
 MsgBox Columns("A:A").Find(What:="", LookAt:=xlWhole).Row
' Cells.FindNext(After:=ActiveCell).Activate
End If

which returns just the first blank cell but as a messagebox.
Any help much appreciated

teepee - 16 Feb 2008 14:59 GMT
Many thanks Jim
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.