+ Reply to Thread
Results 1 to 4 of 4

Two Macro's on one sheet

Hybrid View

Josebug Two Macro's on one sheet 04-22-2019, 11:12 PM
humdingaling Re: Two Macro's on one sheet 04-22-2019, 11:14 PM
Josebug Re: Two Macro's on one sheet 04-22-2019, 11:21 PM
Josebug Re: Two Macro's on one sheet 04-22-2019, 11:59 PM
  1. #1
    Registered User
    Join Date
    04-22-2019
    Location
    Australia
    MS-Off Ver
    Windows 7 enterpirse
    Posts
    8

    Two Macro's on one sheet

    Hi,
    I have the following which works a treat in range "h:h", but I want it to do the same thing for m:m and p:p
    Any ideas?

    Private Sub Worksheet_Change(ByVal Target As Range)
    'Update 20140722
    Dim WorkRng As Range
    Dim Rng As Range
    Dim xOffsetColumn As Integer
    Set WorkRng = Intersect(Application.ActiveSheet.Range("h:h"), Target)
    xOffsetColumn = 1
    If Not WorkRng Is Nothing Then
        Application.EnableEvents = False
        For Each Rng In WorkRng
            If Not VBA.IsEmpty(Rng.Value) Then
                Rng.Offset(0, xOffsetColumn).Value = Now
                Rng.Offset(0, xOffsetColumn).NumberFormat = "dd/mm/yy"
            Else
                Rng.Offset(0, xOffsetColumn).ClearContents
            End If
        Next
        Application.EnableEvents = True
    End If
    End Sub
    Last edited by Josebug; 04-22-2019 at 11:59 PM.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Two Macro's on one sheet

    Set WorkRng = Intersect(Application.ActiveSheet.Range("h:h","m:m","p:p"), Target)
    Last edited by humdingaling; 04-22-2019 at 11:19 PM. Reason: remove rule as OP complied
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    04-22-2019
    Location
    Australia
    MS-Off Ver
    Windows 7 enterpirse
    Posts
    8

    Re: Two Macro's on one sheet

    Unfortunately that did not work. Error message pops up and code no longer functions.

  4. #4
    Registered User
    Join Date
    04-22-2019
    Location
    Australia
    MS-Off Ver
    Windows 7 enterpirse
    Posts
    8

    Re: Two Macro's on one sheet

    Quote Originally Posted by humdingaling View Post
    Set WorkRng = Intersect(Application.ActiveSheet.Range("h:h","m:m","p:p"), Target)
    Managed to get it working with the following changes:
    Set WorkRng = Intersect(Application.ActiveSheet.Range("H:H,M:M,P:P"), Target)
    Thanks for your help, much appreciated.

+ 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. [SOLVED] Macro updating after selecting another sheet and back to Macro enabled sheet?
    By Imran Magsi in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-29-2016, 04:38 AM
  2. [SOLVED] Macro to copy data from a master sheet to separate sheet as per date using a macro
    By tmaster81 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-23-2014, 08:05 AM
  3. Macro to gnereate new sheet which includes the macro to generate a new sheet
    By jocanon in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-27-2013, 05:15 PM
  4. [SOLVED] Macro running on active sheet instead of sheet defined in macro
    By davegscott in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-19-2013, 02:04 PM
  5. [SOLVED] Macro to Copy Data from one Sheet A to Sheet B based on value in cell on sheet A
    By scass in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-11-2012, 07:21 PM
  6. Replies: 1
    Last Post: 07-30-2012, 02:35 PM
  7. [SOLVED] When sheet is activated, execute macro in other sheet and return to sheet
    By timtim89 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-16-2012, 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