+ Reply to Thread
Results 1 to 2 of 2

Excel 2003 VBA - need help with a macro

  1. #1
    Registered User
    Join Date
    02-17-2010
    Location
    Minnesota
    MS-Off Ver
    Excel 2003
    Posts
    1

    Excel 2003 VBA - need help with a macro

    Hey all,

    I'm relatively new to writing macro's, so be gentle. What I want to do is start in one workbook, open another workbook using the getopenfilename command, copy and paste several cells from the opened workbook into the initial workbook, then close the one that was opened using getopenfilename. My problem is, I want to do this several times, so the code needs to recognize that the filenames are changing. I tried passing the value from getopenfilename into the activate commands, but I clearly am out of my league already. Can anyone help? The code is posted below:

    IdatafromIVtrace Macro
    ' Macro recorded 2/17/2010 by Dave
    '

    '
    FileToOpen = Application _
    .GetOpenFilename()
    If FileToOpen <> False Then
    End If

    Workbooks.OpenText Filename:=FileToOpen, _
    DataType:=xlDelimited, Tab:=True

    Range("D1:E1").Select
    Selection.Copy
    Windows("Book1").Activate
    ActiveSheet.Paste
    Windows(FileToOpen).Activate
    Range("B11,G11").Select
    Range("G11").Activate
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Book1").Activate
    Range("C1").Select
    ActiveSheet.Paste
    Windows("021010 445pm PL1.xls").Activate
    Range("P5").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Book1").Activate
    Range("E1").Select
    ActiveSheet.Paste
    Windows("021010 445pm PL1.xls").Activate

    ActiveWorkbook.Close




    End Sub

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Excel 2003 VBA - need help with a macro

    Welcome to the forum.

    Please take a few minutes to read the forum rules, amend your thread title accordingly, and edit your post to add code tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1