View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
mudraker[_288_] mudraker[_288_] is offline
external usenet poster
 
Posts: 1
Default Appending new data to existing data in a spreadsheet

excelmonkey

here are 2 ways to get vacant row & column numbers.

Watch the auto word wraps.



RowNo = Range("a" & Rows.Count).End(xlUp).Row + 1
ColNo = Cells(1, Columns.Count).End(xlToLeft).Column + 1

GetBottomRow = TheSheet.Cells.Find(What:="*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row + 1

LastColumn = TheSheet.Cells.Find(What:="*", SearchOrder:=xlByColumns
_
SearchDirection:=xlPrevious).Column + 1

The following code gives 3 examples of using offset

sub TestOffset()
Dim GetBottomRow As Long
Dim LastColumn As Integer

GetBottomRow = Cells.Find(What:="*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row

LastColumn = Cells.Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column

Range("a1").Offset(GetBottomRow) = "hi"
Range("a1").Offset(GetBottomRow, LastColumn) = "abc"
Range("a1").Offset(0, LastColumn) = "welcome"
End Su

--
Message posted from http://www.ExcelForum.com