+ Reply to Thread
Results 1 to 6 of 6

When I Run This Macro Then Prompt A ("Workbook Name") Option Box

Hybrid View

  1. #1
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,095

    Post When I Run This Macro Then Prompt A ("Workbook Name") Option Box

    DEAR RESPECTED SIR need ur help

    When I Run This Macro I Want To Prompt A MsgBox or Option Box Who Asked For Choose The File Name ( workbook name ) Option
    and then copy data range from active worksheet to workbook name
    in this code source workbook name is ("5.3.14") and destination workbook name is ("6.3.14")
    i want always prompt a box who asked for destination workbook name and then copy data to new workbook name

    Sub copypaste()
    '
    ' copypaste Macro
    '
    
    '
    
        Range("C10:G11").Select
        Range(Selection, Selection.End(xlDown)).Select
        ActiveSheet.Range("$A$9:$I$500").AutoFilter Field:=9, Criteria1:=">0", _
            Operator:=xlAnd
        Selection.Copy
        Windows("6.3.14.xlsm").Activate
        Range("C61").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Windows("5.3.14.xlsm").Activate
        Range("G64").Select
    End Sub
    Last edited by HaroonSid; 03-07-2014 at 10:04 AM. Reason: solved

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,861

    Re: WHEN I RUN THIS MACRO THEN Prompt A ("WORKBOOK NAME") OPTION BOX

    check such proposition:
    Sub copypaste2()
    Dim FileName As Variant
    Dim SourceFile as Workbook, MainFile as workbook : Set MainFile=ThisWorkbook
    
    FileName = Application.GetOpenFilename(filefilter:="Excel files (*.xls*),*.xls*", FilterIndex:=3, Title:="Choose a file")
    If FileName = False Then  
       MsgBox "No file selected!", vbcritical
       Exit Sub
    else
    ' here your code:
        Range("C10:G11").Select
        Range(Selection, Selection.End(xlDown)).Select
        ActiveSheet.Range("$A$9:$I$500").AutoFilter Field:=9, Criteria1:=">0", _
            Operator:=xlAnd
        Selection.Copy
    
    'changed
        Workbooks.Open(Filename)
        Range("C61").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    
    'changed: 
       msgbox "finished copying from " & Filename      
    'and either:
       sourcefile.close false
    'or (remove comment char = ' below and add above)
    '   Mainfile.activate
    
        Range("G64").Select
    
    'added 
    end if
    End Sub
    Best Regards,

    Kaper

  3. #3
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,095

    Re: WHEN I RUN THIS MACRO THEN Prompt A ("WORKBOOK NAME") OPTION BOX

    hey thanx for reply Kaper

    i m getting this error :
    Capture.JPG

    i m using ms office 2013 with .xlsm

    and where i want to paste data the sheet name is "Entry"
    Last edited by HaroonSid; 03-05-2014 at 06:12 AM.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,861

    Re: WHEN I RUN THIS MACRO THEN Prompt A ("WORKBOOK NAME") OPTION BOX

    Change here:
    'and either:
       ActiveWorkbook.Close 
    'or (remove comment char = ' below and add above)
    or attach a sample (not real data of course) workbooks to test with.

    PS. Note my message - especially about editing CapsLocked title look into your http://www.excelforum.com/private.php?folderid=0
    Last edited by Kaper; 03-05-2014 at 08:57 AM.

  5. #5
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,095

    Re: WHEN I RUN THIS MACRO THEN Prompt A ("WORKBOOK NAME") OPTION BOX

    sir not working i m ataching a jpg imag file of both workbook

    Capture.jpg

  6. #6
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,095

    Post Re: When I Run This Macro Then Prompt A ("Workbook Name") Option Box

    thanx a lot sir :


    its working now.....i m not pasting code in write way

    now working

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Only "save" option in save prompt while closing excel sheet
    By rudswa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2013, 08:07 PM
  2. [SOLVED] Invoice "Current" or "Overdue" (but need "Paid" option)
    By rwatson in forum Excel General
    Replies: 5
    Last Post: 04-05-2012, 12:16 PM
  3. Replies: 1
    Last Post: 03-18-2012, 11:09 PM
  4. Replies: 0
    Last Post: 01-04-2006, 06:55 PM
  5. Stop users from accessing "Protection" option from "Tools" menu
    By I Believe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2005, 10:50 AM

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