Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open dialog box. Can Introduce an If ....Else If statement??

Status
Not open for further replies.

romij29

Technical User
Nov 23, 2004
49
GB
I have got a code for opening a file and copying data into another sheet.I have two files that I need to open and copy data from their only sheets into a workbook with two destination sheets. In short, two workbooks (each with a sheet) copied into one workbook(2 different sheets).
Currently, my macro pops up a open dialog box,i select a specific file(Trading files monthly) from a folder labelled trading accounts and open and copy and paste is done. Then another open dialog box pops up and another file is chosen (Retail monthly files) from a folder (retail reports).
I feel this is to cumbersome and I want to introduce an If
ElseIf statement into this .
A newbie and not sure how??any ideas.

Code is as ffs:

Sub mnuFileOpen_Click()
Dim FullFileName As String
Dim RetailPath As String
Dim wbThis As Workbook, wbTrad As Workbook, wbRet As Workbook

Set wbThis = ActiveWorkbook

FullFileName = Application.GetOpenFilename("Excel Files (*.xls),*.xls", False)

Application.StatusBar = "Opening " & FullFileName
Set wbTrad = Workbooks.Open(FullFileName)

wbTrad.Sheets(1).Range("A:H").Copy
wbThis.Sheets("FMA Data").Range("A1").PasteSpecial xlValues

Application.CutCopyMode = False

Application.StatusBar = "Closing " & FullFileName

wbTrad.Close

Application.StatusBar = False

RetailPath = Application.GetOpenFilename("Excel Files (*.xls),*.xls", False)

Application.StatusBar = "Opening " & RetailPath

Set wbRet = Workbooks.Open(RetailPath)

wbRet.Sheets(1).Range("A:H").Copy
wbThis.Sheets("Retail FMA").Range("A1").PasteSpecial xlValues

wbThis.Activate
ActiveWorkbook.Sheets("Retail FMA").Range("A1:H1").Select
Selection.Delete Shift:=xlUp

Application.CutCopyMode = False

Application.StatusBar = "Closing " & RetailPath

wbRet.Close

Application.StatusBar = False

End Sub
 
Hello,

Put the above question on yesterday??Anybody with any ideas??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top