Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All,
I am trying this thing to work but its not working as I want. Lets say I have a button "Export" on the userform, This userform has a dropdown menu, which has student names, and selecting a student name from that dropdown would populate other fields on the form such as, Name, Age, Task etc.. So if i select Student1 from the dropdown, I will get the data of Student1 displayed on the form, If i select Student2 from the dropdown, I will get data of Student2 displayed on the form. Now when I click export, I want it to: - open a file dialog box that lets me select another empty excel file - once i select the excel file, i want the details of the select student to be displayed in Row1 -If i select another student from the dropdown, i want the details of that student to be displayed in Row2... and so on.. - Once I am done selecting the students, I want to manualy save the excel file where I exported the student data. Here is my code for the process: Private Sub ExportToExcel_Click() Dim exApp As Object Dim exl As Object Dim fdialog As FileDialog Dim pathAndFile As String Dim filePath As String Dim shortName As String Dim newWks As Workbook Dim DestCell As Range Dim FName As String filePath = "C:\My Documents\Students.xls" On Error Resume Next Set exApp = GetObject(, "Excel.Application") exApp.Visible = True Set fdialog = exApp.FileDialog(msoFileDialogFilePicker) With fdialog .AllowMultiSelect = False .Filters.Clear .InitialFileName = filePath & "\*.xls*" If .Show Then pathAndFile = .SelectedItems(1) shortName = Right(pathAndFile, _ Len(pathAndFile) - InStrRev(pathAndFile, "\")) Else MsgBox "User cancelled. Did not select a file" End If End With Set newWks = exApp.Workbooks.Open(pathAndFile) With newWks Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0) End With With DestCell .Value = Me.Student_Id.Value .Offset(0, 1).Value = Me.FirstName.Value .Offset(0, 2).Value = Me.LastName.Value End With End Sub Thanks in Advance |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Export Data into another sheet | Excel Discussion (Misc queries) | |||
Export Specific Sheet in Listbox to New Workbook | Excel Programming | |||
Send data from userform to specific cell on specific sheet? | Excel Programming | |||
export excel data to another sheet | Excel Programming | |||
Export specific cell data to txt delimited file | Excel Programming |