+ Reply to Thread
Results 1 to 7 of 7

Two macro problem

  1. #1
    Registered User
    Join Date
    06-22-2010
    Location
    Airdrie, Scotland
    MS-Off Ver
    365
    Posts
    42

    Two macro problem

    Hi,

    I have a 'Log' macro on my workbook using this code: -

    Please Login or Register  to view this content.
    I also have an 'update' macro which copies a block of cells from one area of a worksheet to another. My problem is that when I now run the update macro I am getting a run time error '13': Type mismatch - which highlights the first line of my 'Log' code as being the problem.

    Can anyone tell me a way around this please?

    Many thanks in advance.

    Alan.
    Last edited by Theangelp; 04-25-2017 at 10:05 AM.

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Two macro problem

    The error you experience there is not reproducible here. What does occur however is multiple entries of the time and date from row 1 to row 84.
    And, each row has several entries extending to the right.

    I believe from your code you are wanting to time stamp each entry ? If that is the case, here is another macro that you can work with. It know it
    will require some editing to display as you require but if you experiment with it I am certain you can quickly grasp the code's intent:


    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: Two macro problem

    Does the 'update' macro disable and re-enable events?

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Two macro problem

    Do you mean :

    Please Login or Register  to view this content.
    Ooops ... sorry .. you meant HIS update macro.

    That's ok though, cuz I should have added these lines anyways.

    Hey Sparks !

  5. #5
    Registered User
    Join Date
    06-22-2010
    Location
    Airdrie, Scotland
    MS-Off Ver
    365
    Posts
    42

    Re: Two macro problem

    No. My code is :

    [CODE]Sub CopyPrevious()
    '
    ' CopyPrevious Macro
    '

    '
    Application.ScreenUpdating = False
    Columns("G:J").Select
    Selection.Copy
    Columns("K:K").Select
    ActiveSheet.Paste
    Range("K12").Select
    ActiveCell.FormulaR1C1 = "Previous Quarter"
    Range("K3").Select
    ActiveCell.FormulaR1C1 = _
    "=""Comments were last copied over on ""&TEXT(TODAY(),""dd/mm/yy"")"
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Range("A1").Select
    Application.CutCopyMode = False

    End Sub[CODE]

  6. #6
    Registered User
    Join Date
    06-22-2010
    Location
    Airdrie, Scotland
    MS-Off Ver
    365
    Posts
    42

    Re: Two macro problem

    Thanks Logit. I'll give this a try. Much appreciated.

  7. #7
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: Two macro problem

    You need to control Events.

    Try running your CopyPrevious macro using the F8 key to step through one line at a time and see exactly where the code goes.

    Then add the disable and re-enable event lines and F8 through again to see the difference.
    Please Login or Register  to view this content.
    Google up on disabling/re-enabling events in VBA.
    If you have an error in your code or exit the sub with events disabled nothing works like it should.

+ 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 problem - loops theough user defined functions not called in macro
    By beccyclaire in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-04-2016, 02:09 AM
  2. Problem with recording a macro with long formula - works in Excel but not in macro
    By tonybeo2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-28-2015, 11:25 AM
  3. [SOLVED] Excel Macro - Copy & Paste (Font) problem & Delete Last Added Rows problem
    By LennartB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-05-2015, 06:58 AM
  4. Macro template good saved but running macro with imported data problem
    By brazilexcel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-18-2015, 10:42 PM
  5. Macro Problem with VBA need Help (copy past cells with macro and message box)
    By Nissort in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2013, 12:17 PM
  6. Problem using formulas within macro + problem with defined name.
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2011, 04:39 AM
  7. Replies: 3
    Last Post: 03-20-2006, 01:25 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