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 / Worksheet Functions / June 2007

Tip: Looking for answers? Try searching our database.

How do I find the next blank cell in a range?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
EazyCure - 11 Jun 2007 17:13 GMT
Hey there all -
I am sure that this is terribly simple, but it has eluded me thus far.  I am
trying to figure out how to find the first blank cell in a range.  I am
working on creating a time sheet, and I need to be able to find the first
blank cell in a specific range of cells.  I have found information on finding
the first blank cell in a single column, but this will be a two column range
that I am working with.  Any help would be greatly appreciated.
Ron Coderre - 11 Jun 2007 17:31 GMT
I'm guessing that there's more to this story....

What do you ultimately want to do after you find the blank cell?

***********
Regards,
Ron

XL2002, WinXP

> Hey there all -
> I am sure that this is terribly simple, but it has eluded me thus far.  I am
[quoted text clipped - 3 lines]
> the first blank cell in a single column, but this will be a two column range
> that I am working with.  Any help would be greatly appreciated.
EazyCure - 11 Jun 2007 17:41 GMT
After finding the blank cell I am going to enter the current date and time.  
In the end I am going to write a macro where with the click of a button the
current date and time will be entered into the first available cell, I just
got hung up trying to find the first available cell.
Dave Peterson - 11 Jun 2007 17:53 GMT
Say your range is A1:B9999

And both A9999 and B1 are the first blank cells in each column.

Which is the first blank cell in that range (A1:B9999)?

No matter what you respond, you may want to look at
.specialcells(xlcelltypeblanks).cells(1).  The question is what to apply it to.

It's the equivalent of selecting a range and hitting
edit|goto|special|Blanks
and then using the first cell in that reduced range.

> After finding the blank cell I am going to enter the current date and time.
> In the end I am going to write a macro where with the click of a button the
> current date and time will be entered into the first available cell, I just
> got hung up trying to find the first available cell.

Signature

Dave Peterson

EazyCure - 11 Jun 2007 18:08 GMT
First blank would be B1.  (Left to right, then top to bottom).
Dave Peterson - 11 Jun 2007 21:14 GMT
You can loop backwards through the columns:

Option Explicit
Sub testme01()

   Dim FirstEmptyCell As Range
   Dim wks As Worksheet
   Dim myRng As Range
   Dim iCol As Long
   
   Set wks = Worksheets("sheet1")
   
   With wks
       Set myRng = .Range("a1:B20")
   End With
   
   With myRng
       For iCol = .Columns.Count To 1 Step -1
           Set FirstEmptyCell = Nothing
           On Error Resume Next
           Set FirstEmptyCell _
               = .Columns(iCol).Cells.SpecialCells(xlCellTypeBlanks).Cells(1)
           On Error GoTo 0
       
           If FirstEmptyCell Is Nothing Then
               'keep looking
           Else
               Exit For
           End If
       Next iCol
   End With
   
   If FirstEmptyCell Is Nothing Then
       MsgBox "No empty cells!"
   Else
       MsgBox FirstEmptyCell.Address
   End If
   
End Sub

Be aware that .specialcells() only looks at the used range.  I'm not sure if
that's a problem for you.

> First blank would be B1.  (Left to right, then top to bottom).

Signature

Dave Peterson

Lori - 11 Jun 2007 19:46 GMT
With the range selected, choose Edit>Find [blank] to locate the next
blank cell.

> After finding the blank cell I am going to enter the current date and time.
> In the end I am going to write a macro where with the click of a button the
> current date and time will be entered into the first available cell, I just
> got hung up trying to find the first available cell.
 
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.