Easy VBA help needed

Pinter

New Member
Joined
May 8, 2002
Messages
24
This is a very basic VBA problem, Im sure. I just dont know that much about it yet.

I have a macro written that opens a file which you select, cuts a certain range of values from it, and pastes them into the current file. How do I get the macro to close the file after its done cutting and pasting? Thanks in advance.

Pinter
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Sure. Here it is. Thanks!


Private Sub cmdBrowse1_Click()
'use the common open dialog to get a filename
cmnd.InitDir = "c:\"
cmnd.Filter = "xls (*.xls)|*.xls"
cmnd.ShowOpen

'set the file name
txtFileName = cmnd.FileTitle

txtFileName1 = txtFileName & ".Regulated"

Workbooks.Open txtFileName
Sheets(2).Select
Sheets(2).Range("A1:BB200").Select
Selection.Copy
ThisWorkbook.Sheets(2).Activate
Sheets(2).Range("A1:BB200").Select
ActiveSheet.Paste
Application.CutCopyMode = False

Workbooks.Open txtFileName
Sheets(3).Select
Sheets(3).Range("A1:BB200").Select
Selection.Copy
ThisWorkbook.Sheets(3).Activate
Sheets(3).Range("A1:BB200").Select
ActiveSheet.Paste


Application.CutCopyMode = False
ThisWorkbook.Sheets(1).Activate
MsgBox ("Please select file of case 2.")
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,709
Messages
6,161,431
Members
451,705
Latest member
Priti_190

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top