Hi :) Why do you want to do that with the poor user? (he will have to re-open it and probably with macros turned off)
You can Protect the sheet or Set the scroll area by putting this code : Sheets("name").scrollArea="A1:Z10" If you anyway want to close the workbook, this can help write If not isblank(target) then:thisworkbook.close(false) inside worksheet_change() event With regards Hemant Hegde On 10/11/2009, OSAVentures Calamba <osav...@gmail.com> wrote: > > Dear Paul and gurus, > > I want to find the last row. Is this OK? > > Private Sub Worksheet_Change(ByVal Target As Range) > > Dim LastRow As Long > > If WorksheetFunction.CountA(Cells) > 0 Then > 'Search for any entry, by searching backwards by Rows. > LastRow = Cells.Find(What:="*", After:=[A1], _ > SearchOrder:=xlByRows, _ > SearchDirection:=xlPrevious).Row > MsgBox LastRow & " You cant go beyond this workbook closed." > > end sub > > or somthing like this. > > Private Sub Worksheet_Change(ByVal Target As Range) > > Dim LastRow As Long > LastRow = ActiveSheet.UsedRange.Rows.Count > if LastRow=>10 then > > MsgBox LastRow & " You cant go beyond this workbook closed." > endif > end sub > > Thanks > > On Mon, Nov 9, 2009 at 8:34 PM, Paul <schreiner_p...@att.net> wrote: > >> >> What do you mean by "last row with data = 10"? >> do you mean that row #10 has data? >> or that the last row with data has a VALUE of 10 in a specific column? >> will there be data in rows 1-9? >> What columns will the data be in? look for ANY data in row 10? >> >> What do you want to use to trigger the event? >> When does the last row change to 10? >> >> do you want to save the workbook when it closes? >> >> You could create an event: >> Private Sub Worksheet_Change(ByVal Target As Range) >> >> test for whatever you're testing for: >> If (Target.Row = 10) then >> >> then: >> >> >> ThisWorkbook.Close savechanges:=False >> >> >> >> >> On Nov 8, 11:31 pm, OSAVentures Calamba <osav...@gmail.com> wrote: >> > dear gurus, >> > >> > i need to close a workbook if last row with data =10, Any VBA >> suggestion >> > please? >> > >> > dellosa >> >> > > > > -- Hemant Hegde --~--~---------~--~----~------------~-------~--~----~ ---------------------------------------------------------------------------------- Some important links for excel users: 1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at http://www.excelitems.com 2. Excel tutorials at http://www.excel-macros.blogspot.com 3. Learn VBA Macros at http://www.vbamacros.blogspot.com 4. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com If you find any spam message in the group, please send an email to: Ayush Jain @ jainayus...@gmail.com or Ashish Jain @ 26may.1...@gmail.com <><><><><><><><><><><><><><><><><><><><><><> HELP US GROW !! We reach over 6,500 subscribers worldwide and receive many nice notes about the learning and support from the group. Our goal is to have 10,000 subscribers by the end of 2009. Let friends and co-workers know they can subscribe to group at http://groups.google.com/group/excel-macros/subscribe -~----------~----~----~----~------~----~------~--~---