Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DOV DOV is offline
external usenet poster
 
Posts: 4
Default last non-empthy cell

hi, i need to "tell" the macro to move the coursor to the first empthy cell
in a coloumn, how to do that?

thanks, dov

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default last non-empthy cell

One way is to look at the top cell. then the second, then slide down to the
bottom if both are non-empty:

Option Explicit
Sub testme()

Dim DestCell As Range
Dim iCol As Long

iCol = 6

With Worksheets("sheet1")
If IsEmpty(.Cells(1, iCol)) Then
Set DestCell = .Cells(1, iCol)
ElseIf IsEmpty(.Cells(2, iCol)) Then
Set DestCell = .Cells(2, iCol)
Else
Set DestCell = .Cells(1, iCol).End(xlDown).Offset(1, 0)
End If
End With

DestCell.Select

End Sub

I used iCol = 6 (column F) in my example.

dov wrote:

hi, i need to "tell" the macro to move the coursor to the first empthy cell
in a coloumn, how to do that?

thanks, dov


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default last non-empthy cell

Dim rng as Range
on Error resume Next
set rng = columns(3).SpecialCells(xlBlanks)(1)
On Error goto 0
if rng is nothing then
set rng = cells(rows.count,1).End(xlup)
End if
msgbox "Next empty cell is " & rng.Address

--
Regards,
Tom Ogilvy


"dov" wrote in message
...
hi, i need to "tell" the macro to move the coursor to the first empthy

cell
in a coloumn, how to do that?

thanks, dov



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default last non-empthy cell

Need another line:

Dim rng as Range
on Error resume Next
set rng = columns(3).SpecialCells(xlBlanks)(1)
On Error goto 0
if rng is nothing then
set rng = cells(rows.count,1).End(xlup)
End if
if not isempty(rng) then set rng = rng.offset(1,0)
msgbox "Next empty cell is " & rng.Address

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Dim rng as Range
on Error resume Next
set rng = columns(3).SpecialCells(xlBlanks)(1)
On Error goto 0
if rng is nothing then
set rng = cells(rows.count,1).End(xlup)
End if
msgbox "Next empty cell is " & rng.Address

--
Regards,
Tom Ogilvy


"dov" wrote in message
...
hi, i need to "tell" the macro to move the coursor to the first empthy

cell
in a coloumn, how to do that?

thanks, dov





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default last non-empthy cell

Dov,

To simply select the cell:
ActiveSheet.Range("A" & ActiveSheet.Rows.Count).End
(xlUp).Offset(1,0).Select

Or, to get the row number:

Dim lRow as Long
lRow = ActiveSheet.Range("A" & ActiveSheet.Rows.Count).End
(xlUp).Row + 1
Range("A" & lRow).Value = "Next Cell"

Cheers,
Dave
-----Original Message-----
hi, i need to "tell" the macro to move the coursor to the

first empthy cell
in a coloumn, how to do that?

thanks, dov

.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default last non-empthy cell

Perhaps this function will do:

lastrow = lastcell(worksheetname)
Cells(lastcell, colnum).Select

Function lastcell(wsname)
Sheets(wsname).Select
lastcell = Application.WorksheetFunction.CountA(Columns("A:A" ))
End Function

Hi, Stefi


€ždov€ť ezt Ă*rta:

hi, i need to "tell" the macro to move the coursor to the first empthy cell
in a coloumn, how to do that?

thanks, dov

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
How do I calculate a weighted average and exclude the empthy cells aganoe Excel Worksheet Functions 2 May 28th 10 04:34 AM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Excel Discussion (Misc queries) 0 June 29th 09 11:20 AM
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Yuvraj Excel Discussion (Misc queries) 0 June 26th 09 06:01 PM
Populate a cell if values in cell 1 and cell 2 match cell 3 and 4 [email protected] Excel Worksheet Functions 1 August 22nd 08 02:04 AM
How to create/run "cell A equals Cell B put Cell C info in Cell D abmb161 Excel Discussion (Misc queries) 5 January 26th 06 06:36 PM


All times are GMT +1. The time now is 07:07 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"