ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   get all sheet names in comboBox of activeworkbook and export when selected (https://www.excelbanter.com/excel-programming/331503-get-all-sheet-names-combobox-activeworkbook-export-when-selected.html)

ilyaskazi[_26_]

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


Nigel

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




EMoe[_28_]

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


ilyaskazi[_27_]

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


Dave Peterson[_5_]

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

ilyaskazi[_29_]

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



All times are GMT +1. The time now is 05:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com