Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default get all sheet names in comboBox of activeworkbook and export when selected


get all sheet names (even hidden or very hidden sheets) in comboBox of
the activeWorkbook upon loading Userform.

If the specific sheet is selected then export that sheets in already
opened workbook(MyProject.xls) when 'cmdImport' button is clicked.


--
ilyaskazi
------------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...o&userid=23969
View this thread: http://www.excelforum.com/showthread...hreadid=378269

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default get all sheet names in comboBox of activeworkbook and export when selected

Following code lists all sheets in activeworkbook in combobox1, if user
chooses a sheet it is copied into the MyProjects.xls at the end.
Hopefully gives you a starter for 10. Place code behind the userform.

Option Explicit
Dim ws As Integer

Private Sub ComboBox1_Change()
Worksheets(ComboBox1.Value).Copy
After:=Workbooks("MyProjects.xls").Sheets(Sheets.C ount)
End Sub

Private Sub UserForm_Initialize()
For ws = 1 To Worksheets.Count
ComboBox1.AddItem Worksheets(ws).Name
Next
End Sub

--
Cheers
Nigel



"ilyaskazi" wrote
in message ...

get all sheet names (even hidden or very hidden sheets) in comboBox of
the activeWorkbook upon loading Userform.

If the specific sheet is selected then export that sheets in already
opened workbook(MyProject.xls) when 'cmdImport' button is clicked.


--
ilyaskazi
------------------------------------------------------------------------
ilyaskazi's Profile:

http://www.excelforum.com/member.php...o&userid=23969
View this thread: http://www.excelforum.com/showthread...hreadid=378269



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default get all sheet names in comboBox of activeworkbook and export when selected


Hello,

Can you copy only a range (let's say A1:I50) on the activesheet, if
needed to.

Thanks,
EMoe


--
EMoe
------------------------------------------------------------------------
EMoe's Profile: http://www.excelforum.com/member.php...o&userid=23183
View this thread: http://www.excelforum.com/showthread...hreadid=378269

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default get all sheet names in comboBox of activeworkbook and export when selected


it gives me debug msg when i try to copy next sheet

only 1 sheet is possible with the abv code???


--
ilyaskazi
------------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...o&userid=23969
View this thread: http://www.excelforum.com/showthread...hreadid=378269

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default get all sheet names in comboBox of activeworkbook and export whenselected

I put a combobox and two commandbuttons on a userform.

This was the code behind the userform:

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()

Dim myVisible As Long
Dim ToWkbk As Workbook
Dim ToWkbkName As String
Dim wksName As String
Dim myWindow As Window

Set myWindow = ActiveWindow

ToWkbkName = "myproject.xls"

If Me.ComboBox1.ListIndex < 0 Then
Beep
Exit Sub 'nothing selected
End If

Set ToWkbk = Nothing
On Error Resume Next
Set ToWkbk = Workbooks(ToWkbkName)
On Error GoTo 0

If ToWkbk Is Nothing Then
MsgBox "Please open: " & ToWkbkName & " first!"
Exit Sub
End If

wksName = Me.ComboBox1.Value

With ActiveWorkbook.Worksheets(wksName)
Application.ScreenUpdating = False
myVisible = .Visible
.Visible = xlSheetVisible
.Copy _
after:=ToWkbk.Sheets(ToWkbk.Sheets.Count)
.Visible = myVisible
myWindow.Activate
Application.ScreenUpdating = True
End With

End Sub
Private Sub UserForm_Initialize()
Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
Me.ComboBox1.AddItem wks.Name
Next wks
End Sub


ilyaskazi wrote:

get all sheet names (even hidden or very hidden sheets) in comboBox of
the activeWorkbook upon loading Userform.

If the specific sheet is selected then export that sheets in already
opened workbook(MyProject.xls) when 'cmdImport' button is clicked.

--
ilyaskazi
------------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...o&userid=23969
View this thread: http://www.excelforum.com/showthread...hreadid=378269


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default get all sheet names in comboBox of activeworkbook and export when selected


thankyou dave,

it is exactly as wanted. :

--
ilyaskaz
-----------------------------------------------------------------------
ilyaskazi's Profile: http://www.excelforum.com/member.php...fo&userid=2396
View this thread: http://www.excelforum.com/showthread.php?threadid=37826

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
Mutiple names in ActiveWorkbook.SendMail Recipients:= daleatshel Excel Discussion (Misc queries) 2 February 5th 07 08:06 PM
populate combobox with sheet names David Goodall Excel Programming 3 September 12th 04 12:37 PM
populate combobox with sheet names David Goodall Excel Programming 0 September 12th 04 08:55 AM
Populating sheet names in combobox Todd Huttenstine[_2_] Excel Programming 3 December 21st 03 12:11 AM
Using ActiveWorkbook.Names.Add Name:= Stuart[_5_] Excel Programming 2 November 15th 03 02:38 PM


All times are GMT +1. The time now is 03:34 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"