Sorry I don't understand from which line the code get the list of sheets names? There is no (for.. next) in code Thank u very much
-----Original Message----- From: excel-macros@googlegroups.com [mailto:excel-mac...@googlegroups.com] On Behalf Of Ashish Jain Sent: Friday, October 22, 2010 10:34 AM To: MS EXCEL AND VBA MACROS Subject: $$Excel-Macros$$ Re: help in understanding code Hi Omar Here is line by line description of the VBA code you provided: Sub OMAR_QUERY() 'Error Handling ON: In case of error, it will skip to next line. On Error Resume Next 'Error handling used specifically for this line of code. 'If there are more than 16 worksheets, it will execute else will throw an error. 'It will display the 'activate' window to activate the worksheet required. Application.CommandBars("Workbook Tabs").Controls("More Sheets...").Execute 'In case of less than 16 sheets, error will be thrown and execution will enter in IF block. If Err.Number > 0 Then 'Clear the error cache. Err.Clear 'It will display a pop-up to activate the worksheet required. Application.CommandBars("Workbook Tabs").ShowPopup 'End of If Block End If 'Scroll to the first column of activated worksheet. ActiveWindow.ScrollColumn = 1 'Scroll to the first row of activated worksheet. ActiveWindow.ScrollRow = 1 'Error Handling OFF On Error GoTo 0 End Sub Regards Ashish Jain McKinsey India Knowledge Center (Microsoft Certified Application Specialist) (Microsoft Certified Professional) On Oct 21, 10:13 pm, عمــــــــــــر <omar27...@gmail.com> wrote: > This code make a popup with sheetsList > > But I don't understand how it works > > On Error Resume Next > > Application.CommandBars("Workbook Tabs").Controls("More > Sheets...").Execute > > If Err.Number > 0 Then > > Err.Clear > > Application.CommandBars("Workbook Tabs").ShowPopup > > End If > > ActiveWindow.ScrollColumn = 1 > > ActiveWindow.ScrollRow = 1 > > On Error GoTo 0 > > Except this > > Application.CommandBars("Workbook Tabs").Controls("More Sheets...").Execute > > If Err.Number > 0 Then > > Err.Clear > > Application.CommandBars("Workbook Tabs").ShowPopup -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts