View Single Post
  #17   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Finding Next Empty Cell in a Range

Yes, you can send the file to me.... just remove the NO.SPAM stuff from my
email address.

--
Rick (MVP - Excel)



"Stilltrader47" wrote in message
...
Rick - I could not get it to run. I attached ctl-d to launch it. It
should
have went to Jan1st, right? If your interested I'll send you the file,
would
appreciate. Tom

"Rick Rothstein" wrote:

It was in the response to my own posting. This is the code I posted
there...

Sub SelectNextEmptyCell()
Dim LastRow As Long, LastDay As Long, EndOfMonth As Long, Jan1st As
Range
Set Jan1st = Range("B2")
LastRow = Jan1st.EntireColumn.Find(What:="*", SearchOrder:=xlColumns, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row
LastDay = Cells(LastRow, Jan1st.Column).End(xlToRight).Column
EndOfMonth = Day(DateSerial(Year(Now), LastRow - Jan1st.Row + 2, 0))
If LastDay - Jan1st.Column + 1 < EndOfMonth Then
Cells(LastRow, LastDay + 1).Select
Else
Cells(LastRow + 1, Jan1st.Column).Select
End If
End Sub

Don't forget to set the Jan1st Range variable to the cell corresponding
to
January 1st.

--
Rick (MVP - Excel)



"Stilltrader47" wrote in
message
...
Rick, where did you post the macro? Thanks - Tom

"Rick Rothstein" wrote:

I just posted a new macro (in response to my previous posting) that
you
may
find interesting... it properly handles the end of month transitions
and
it
is not what I would call "lengthy" code.

--
Rick (MVP - Excel)



"helene and gabor" wrote in message
...
Hello,

I have carried Rick Rothstein's algorithm for considering the
length
of
various months.
The program finds the next empty cell for each month, not selecting
April
31 etc.
The program is rather lengthy because for each month the empty cell
has
to
be found before applying Mr. Rothstein algorithm for moving the
cursor
to
that cell.
I did the project as part of my learning the VBA.
The program is available, but it's not as simple as the requester
has
expected.

Best Regards,

Gabor Sebo

"Stilltrader47" wrote in
message
...
My worksheet is set-up for 12 month price tracking. The entry
range
is
12
rows (months) by 31 columns (days). How can I write a macro that
will
locate
the cursor to the next empty cell in the range? What I am looking
for
is
an
efficient "find" command. I would prefer to execute by
ctl-(letter)
if
possible.

Thanks for helping.


.

.