Help for creating a macro [Closed]

Report
Posts
4
Registration date
Wednesday June 22, 2016
Status
Member
Last seen
June 24, 2016
-
Posts
4
Registration date
Wednesday June 22, 2016
Status
Member
Last seen
June 24, 2016
-
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 reply

Posts
4
Registration date
Wednesday June 22, 2016
Status
Member
Last seen
June 24, 2016

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

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!