Results 1 to 7 of 7

Running two macros in one worksheet at the same time

Threaded View

  1. #1
    Registered User
    Join Date
    07-16-2014
    Location
    ham, ON
    MS-Off Ver
    2007
    Posts
    3

    Running two macros in one worksheet at the same time

    Hello I'm inexperienced in VBA, been digging around and trying different things but I still can't figure out how to get my two macros to run at the same time in the same worksheet. If I open two different excel tabs and use the codes seperately, they each do their own purpose. But I can't figure out how to merge them in one excel worksheet. It seems it's not as easy as just deleting the "End Sub" and "Private Sub Worksheet_Change(ByVal Target As Range)" in the middle to combine them. When I enter something in cell B1 I would like it to cut and paste to the A column (starting at A2) and then also populate the date in the cell next to it. Here are the two macros:


    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Cells.Count > 1 Then Exit Sub
    
            If Not Intersect(Target, Range("A2:A100")) Is Nothing Then
    
                With Target(1, 2)
    
                    .Value = Now
    
                    .EntireColumn.AutoFit
    
                End With
    
            End If
    
    End Sub
    
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Intersect(Target, Me.Range("B1")) Is Nothing Then Exit Sub
        Application.EnableEvents = False 'to prevent endless loop
    
        Dim last_row As Long
         
        last_row = Range("A65536").End(xlUp).Row
         
         
        Range("B1").Copy
        ActiveSheet.Paste Destination:=Range("A" & last_row + 1)
        Range("B1").ClearContents
        Application.CutCopyMode = False
         
    
        Application.EnableEvents = True
    End Sub
    Last edited by JBeaucaire; 07-21-2014 at 10:52 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] how to keep macros from running at the same time?
    By scottatbuckman in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-26-2014, 12:06 PM
  2. Prevent two macros from running at the same time
    By Kreef in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-31-2011, 10:36 PM
  3. Running Macros based on Worksheet changes in Excel 2007
    By Kaigi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-15-2010, 05:52 PM
  4. Running Macros in protected worksheet
    By 37Seconds in forum Excel General
    Replies: 6
    Last Post: 01-09-2007, 03:31 PM
  5. [SOLVED] Editing worksheet while running macros
    By eight02645999@yahoo.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-30-2005, 05:05 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