Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Import Wizard

I have the following code which I have patched together
from some of my code and some I have ripped from past
entries on the Newsgroup but I have hit a brick wall.

I have a worksheet with two sheets. Menu and Table_import.

The macro should import the all the values of the workbook
fname which is generated from the
Application.GetOpenFilename method. It should then add all
sheet names to a list box (lst_sheetnames) I have on a
userform called frm_sheetnames.

The user then select which sheet they want to import in
using a cmd button called cmd_select.

I have two problems with this. for somereason it is not
adding the sheet names to the list box. Also how would I
carry on running the macro when the user clicks cmd_select.

Also when it comes up with the error subscript out of
range and doesnt copy the data from fname?

Any help would be appreciated.

Thanks

Edgar Thoemmes





Sub Import_Wizard()
Dim fname As String
Dim oWb As Workbook
Dim sh As Worksheet
Dim shName As String

'Get file path for import

ChDrive "S"
ChDir "S:\Kingston\FA\Overseas Payments\Overseas Payments
Public\Ed"
fname = Application.GetOpenFilename()

'Check that a file was selected
If fname < "" Then
Set oWb = Workbooks.Open(fname)

'load form
frm_sheetnames.Show

'Copy sheet names to list (lst_sheetnames) on user form
(frm_sheetname)
With Workbooks(fname)
For i = 1 To .Worksheets.Count
frm_sheetname.lst_sheetnames.AddItem = .Worksheets(i).Name
Next i
End With

'Need to change Sheet name to to selected item on list???

oWb.Sheets("TEST11").Range("A1:AQ100").Copy
Windows("Remittance Procedure.xls").Activate
Sheets("Crystal_Table").Select
ActiveSheet.Paste

Else
MsgBox ("Please select a Valid File")

End If
oWb.Close

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Import Wizard

Edgar,

To get the worksheet names in the list box, try replacing this line...
frm_sheetname.lst_sheetnames.AddItem = .Worksheets(i).Name
with...
frm_sheetname.lst_sheetnames.AddItem .Worksheets(i).Name

Regards,
Jim Cone
San Francisco, CA

"Edgar Thoemmes" wrote in message
...
I have the following code which I have patched together
from some of my code and some I have ripped from past
entries on the Newsgroup but I have hit a brick wall.
I have a worksheet with two sheets. Menu and Table_import.
The macro should import the all the values of the workbook
fname which is generated from the
Application.GetOpenFilename method. It should then add all
sheet names to a list box (lst_sheetnames) I have on a
userform called frm_sheetnames.
The user then select which sheet they want to import in
using a cmd button called cmd_select.
I have two problems with this. for somereason it is not
adding the sheet names to the list box. Also how would I
carry on running the macro when the user clicks cmd_select.
Also when it comes up with the error subscript out of
range and doesnt copy the data from fname?
Any help would be appreciated.
Thanks
Edgar Thoemmes


Sub Import_Wizard()
Dim fname As String
Dim oWb As Workbook
Dim sh As Worksheet
Dim shName As String
'Get file path for import
ChDrive "S"
ChDir "S:\Kingston\FA\Overseas Payments\Overseas Payments
Public\Ed"
fname = Application.GetOpenFilename()
'Check that a file was selected
If fname < "" Then
Set oWb = Workbooks.Open(fname)
'load form
frm_sheetnames.Show
'Copy sheet names to list (lst_sheetnames) on user form
(frm_sheetname)
With Workbooks(fname)
For i = 1 To .Worksheets.Count
frm_sheetname.lst_sheetnames.AddItem = .Worksheets(i).Name
Next i
End With
'Need to change Sheet name to to selected item on list???
oWb.Sheets("TEST11").Range("A1:AQ100").Copy
Windows("Remittance Procedure.xls").Activate
Sheets("Crystal_Table").Select
ActiveSheet.Paste
Else
MsgBox ("Please select a Valid File")
End If
oWb.Close
End Sub



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
How to Start Excel in Text Import Wizard for data import rlelvis Setting up and Configuration of Excel 0 July 10th 08 08:40 PM
Help with Text Import Wizard beth Excel Discussion (Misc queries) 1 April 23rd 08 04:30 AM
Run Import Wizard Erika Excel Discussion (Misc queries) 2 January 8th 07 05:03 PM
Text Import Wizard GARY Excel Discussion (Misc queries) 1 December 24th 06 08:40 PM
Import wizard limitation Sirocco Excel Discussion (Misc queries) 1 June 23rd 05 02:06 AM


All times are GMT +1. The time now is 10:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"