Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro trouble finding 'empty' cells

Hi,
i forgot i had this little problem.
i'm trying to paste data to a specific column, for example- F253.
the problem is, it may not be F253 every time (only now they tell me)

what i think would work is to put a line in before the Paste
that finds the first empty cell in the F column. since there is no
data anywhere underneath, seems possible.
is there such a command line to 'find the first empty cell'?

Thanks for any input,

Have a great day!

SF
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default Macro trouble finding 'empty' cells

"foamfollower" wrote in message
om...
is there such a command line to 'find the first empty cell' (in a column)?


This illustrates two methods. The first fails if the column is empty or if
there is data in the last cell. The second finds the second cell if the
column is empty. It also finds some cell further up the column if the last
cell is not empty. If your column always has data in it and never nears the
bottom row, these will work as is. Otherwise you may need to add tests for
special cases.

Sub findit()

Dim r As Range

'1) Use Find.
Set r = Columns("F").Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows)(2)
Application.Goto r
MsgBox r.AddressLocal

'2) Use End
Set r = Columns("F").Cells(Rows.Count).End(xlUp).Offset(1, 0)
Application.Goto r
MsgBox r.AddressLocal

End Sub

Note that the unqualified Column("F") refers to column F in the active
sheet, if it exists. Use
Workbooks("Book1.xls").Worksheets("Sheet1").Column ("F"). etc. or equivalent
to specify a particular worksheet and workbook.

Also, look up Last Cell on Google. This is last-cell (or first empty cell)
thing is a common concern.

--
Bob Kilmer


"foamfollower" wrote in message
om...
is there such a command line to 'find the first empty cell'?



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
Macro to clean empty cells Dr Hackenbush[_2_] Excel Discussion (Misc queries) 0 March 9th 10 11:55 AM
Finding data amongst empty cells James Excel Discussion (Misc queries) 6 November 10th 09 04:35 PM
Finding days between cells C and L where the cells may be empty Jack Excel Worksheet Functions 1 January 9th 06 06:47 PM
Macro to copy value in empty cells Esrei Excel Discussion (Misc queries) 3 April 19th 05 03:54 PM
macro to delete empty cells Tom Ogilvy Excel Programming 3 August 12th 03 08:06 PM


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

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

About Us

"It's about Microsoft Excel"