+ Reply to Thread
Results 1 to 8 of 8

vba to stop the macro to edit data in another work book and resume

  1. #1
    Registered User
    Join Date
    11-25-2017
    Location
    INDIA
    MS-Off Ver
    WINDWS 10
    Posts
    6

    vba to stop the macro to edit data in another work book and resume

    Hi All, Am new to this forum and also not a VBA expert. I written a code to open a workbook(namely X) to copy data and paste it into the workbook(namely Y) where my macro is running. Here i want to edit few lines in the X workbook before copying into my Y workbook. Please help me with code to stop the macro and resume it once i complete my edit work.

    Thanks in advance.

    Regards,
    Karthikha

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: vba to stop the macro to edit data in another work book and resume

    What code do you have so far?
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    11-25-2017
    Location
    INDIA
    MS-Off Ver
    WINDWS 10
    Posts
    6

    Re: vba to stop the macro to edit data in another work book and resume

    Hi Mike, Here is my code...

    Sub copy()
    Dim vFile As Variant
    Dim strdir as string
    Dim wbCopyTo As Workbook
    Dim wsCopyTo As Worksheet
    Dim wbCopyFrom As Workbook
    Dim wsCopyFrom As Worksheet

    Set wbCopyTo = ActiveWorkbook
    Set wsCopyTo = ActiveSheet


    strDir = "C:\
    vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & _
    "*.xl*", 1, "Select Excel File", "Open", False)

    If TypeName(vFile) = "Boolean" Then
    Exit Sub
    Else
    Set wbCopyFrom = Workbooks.Open(vFile)
    Set wsCopyFrom = wbCopyFrom.Worksheets(1)
    End If

    “Here I need a code to stop the macro to remove filters on vfile manually and then to continue macro.
    Note:Vfile is a shared file with password protection.”


    wsCopyFrom.Range("B6:E12").Copy
    wsCopyTo.Range("B5").PasteSpecial Paste:=xlPasteValues, _
    Operation:=xlNone, SkipBlanks:=False, Transpose:=False

    wbCopyFrom.Close SaveChanges:=False

    End Sub
    Last edited by karthikha; 11-25-2017 at 11:01 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,257

    Re: vba to stop the macro to edit data in another work book and resume

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-25-2017
    Location
    INDIA
    MS-Off Ver
    WINDWS 10
    Posts
    6

    Re: vba to stop the macro to edit data in another work book and resume

    Hi Daboho, Thanks for your reply.....Actually copy is not an issue for me.....i want to stop the macro and after removing filters manually, i like to run the balance code..... i am looking for code to stop,edit and then to continue the macro.

  6. #6
    Registered User
    Join Date
    11-25-2017
    Location
    INDIA
    MS-Off Ver
    WINDWS 10
    Posts
    6

    Re: vba to stop the macro to edit data in another work book and resume

    Hi Mike, Here is my code...

    Sub copy()
    Dim vFile As Variant
    Dim strdir as string
    Dim wbCopyTo As Workbook
    Dim wsCopyTo As Worksheet
    Dim wbCopyFrom As Workbook
    Dim wsCopyFrom As Worksheet

    Set wbCopyTo = ActiveWorkbook
    Set wsCopyTo = ActiveSheet


    strDir = "C:\
    vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & _
    "*.xl*", 1, "Select Excel File", "Open", False)

    If TypeName(vFile) = "Boolean" Then
    Exit Sub
    Else
    Set wbCopyFrom = Workbooks.Open(vFile)
    Set wsCopyFrom = wbCopyFrom.Worksheets(1)
    End If

    “Here I need a code to stop the macro to remove filters on vfile manually and then to continue macro.
    Note:Vfile is a shared file with password protection.”


    wsCopyFrom.Range("B6:E12").Copy
    wsCopyTo.Range("B5").PasteSpecial Paste:=xlPasteValues, _
    Operation:=xlNone, SkipBlanks:=False, Transpose:=False

    wbCopyFrom.Close SaveChanges:=False

    End Sub

  7. #7
    Registered User
    Join Date
    11-25-2017
    Location
    INDIA
    MS-Off Ver
    WINDWS 10
    Posts
    6

    Re: vba to stop the macro to edit data in another work book and resume

    Hi All...I found a work around.....Thanks...
    Sub copy()


    Dim vFile As Variant

    Dim wbCopyFrom As Workbook
    Dim wsCopyFrom As Worksheet




    strdir = "D:\"
    vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & _
    "*.xl*", 1, "Select Excel File", "Open", False)

    If TypeName(vFile) = "Boolean" Then
    Exit Sub
    Else
    Set wbCopyFrom = Workbooks.Open(vFile)

    End If

    End Sub
    Sub closee()

    Dim wbCopyTo As Workbook
    Dim wsCopyTo As Worksheet
    Dim wbCopyFrom As Workbook
    Dim wsCopyFrom As Worksheet


    Set wbCopyTo = ActiveWorkbook
    Set wsCopyTo = ActiveSheet

    Set wbCopyFrom = Workbooks(2)
    Set wsCopyFrom = wbCopyFrom.Worksheets(1)


    wsCopyFrom.Range("a2:p1600").copy
    wsCopyTo.Range("a2").PasteSpecial Paste:=xlPasteValues, _
    Operation:=xlNone, SkipBlanks:=False, Transpose:=False

    wbCopyFrom.Close SaveChanges:=False

    Worksheets(1).Range("i2").copy
    ActiveSheet.Range("i3:i1600").PasteSpecial xlPasteFormats
    Application.CutCopyMode = False

    Range("i2").CurrentRegion.Select
    Selection.Sort Key1:=Range("i2"), Order1:=xlAscending, Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal



    End Sub
    Last edited by karthikha; 11-26-2017 at 05:44 AM.

  8. #8
    Registered User
    Join Date
    11-25-2017
    Location
    INDIA
    MS-Off Ver
    WINDWS 10
    Posts
    6

    Re: vba to stop the macro to edit data in another work book and resume

    MID(A9,FIND(", Hrs: ",A9)+LEN(", Hrs: "), FIND(", Mins: ",A9)-FIND(", Hrs: ",A9)-LEN(", Hrs: "))

+ 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. Macro to add Data Labels in all charts available in the whole work book?
    By D2S in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2017, 12:29 PM
  2. Macro- for transfering data from many workbook to master work book
    By rk250150 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2014, 08:04 AM
  3. Trying to edit a master timesheet to spread across all other sheets in work book.
    By dark91zc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-06-2013, 02:02 PM
  4. Macro to import data from different work book and sort
    By jerry499 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-11-2012, 08:34 PM
  5. [SOLVED] Macro to extract data from other work book & add hyperlink
    By SilverFox in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-24-2012, 07:23 AM
  6. Macro to copy data from one excel work book and pase it in another
    By jmsgdin in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-18-2011, 06:34 AM
  7. Stop Macro, Check Cells & Modify if Necessary, Resume Macro
    By AccountantCost in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2009, 07:39 AM

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