Help for creating a macro

Closed
r.rafailov Posts 4 Registration date Wednesday June 22, 2016 Status Member Last seen June 24, 2016 - Jun 24, 2016 at 08:11 AM
r.rafailov Posts 4 Registration date Wednesday June 22, 2016 Status Member Last seen June 24, 2016 - Jun 24, 2016 at 09:30 AM
Hi all. I'm here to ask for ypur help. I want to create a macro, that opens a dialog box and leting you browse your computer and open a new excel file. So far so good. But i want after opening a file to select a column and export it to the file with the macro. Is there a way to keep a macro button floating on top?
The code for opening a file is:

Sub sbVBA_To_Open_Workbook_FileDialog()
Dim strFileToOpen As String
strFileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to open", _
FileFilter:="Excel Files *.xls* (*.xls*),")
If strFileToOpen = "False" Then
MsgBox "No file selected.", vbExclamation, "Sorry!"
Exit Sub
Else
Workbooks.Open Filename:=strFileToOpen
End If
End Sub

Help me what to do next
Thank you in advance!

1 response

r.rafailov Posts 4 Registration date Wednesday June 22, 2016 Status Member Last seen June 24, 2016
Jun 24, 2016 at 09:30 AM
Sub sbVBA_To_Open_Workbook_FileDialog()
Dim strFileToOpen As String
strFileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to open", _
FileFilter:="Excel Files *.xls* (*.xls*),")
If strFileToOpen = "False" Then
MsgBox "No file selected.", vbExclamation, "Sorry!"
Exit Sub
Else
Workbooks.Open Filename:=strFileToOpen
ActiveWindow.Visible = True
With ActiveSheet
.EnableSelection = xlNoSelection

End With
Dim rng As Excel.Range

Set rng = Application.InputBox("Select a range", "Obtain Range Object", Type:=8)
MsgBox "The cells selected were " & rng.Address
rng.Copy
Windows("Microsoft Excel Worksheet.xlsm").Activate
Range("A2").Select
ActiveSheet.Paste
End If
End Sub
0