hi all, i want to learn VBA & Macros, can anybody send example excel file and macro file, kindly do the need ful
thanks & Regards, kumar On Thu, May 14, 2009 at 10:01 PM, Steve <klein.st...@gmail.com> wrote: > > I have a UserForm with a multi-selection ListBox (ListBox1) that is > populated with all the worksheet names. Based on the user's selection > (s), I am trying to export (copy/paste values & formats) for only > those selected worksheets when he/she clicks a CommandButton > (cbRunExport). I keep encountering errors, but I am unable to > pinpoint what I am missing. Seems like I am not capturing the > selection in the ListBox. Any help anyone can provide would be > greatly appreciated! > > > Private Sub UserForm_Initialize() > > Dim WS As Worksheet > For Each WS In ActiveWorkbook.Worksheets > ListBox1.AddItem WS.Name > Next > End Sub > > Private Sub cbRunExport_Click() > Dim Lst As String > Dim x As Long > For x = 0 To ListBox1.ListCount - 1 > Lst = ListBox1.List(x) > Select Case Worksheets(Lst).Visible > > Case Is = xlSheetVisible > Worksheets(Lst).Cells.Copy > Workbooks.Add > Selection.PasteSpecial Paste:=xlValues > Selection.PasteSpecial Paste:=xlFormats > End Select > Next > Unload Me > End Sub > > > --~--~---------~--~----~------------~-------~--~----~ ------------------------------------------------------------------------------------- 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 ------------------------------------------------------------------------------------- -~----------~----~----~----~------~----~------~--~---