+ Reply to Thread
Results 1 to 5 of 5

If-ElseIf-Else Macro has stopped working

  1. #1
    Registered User
    Join Date
    03-10-2013
    Location
    Mukilteo, WA
    MS-Off Ver
    Excel 2007
    Posts
    29

    If-ElseIf-Else Macro has stopped working

    Hi - I have a basic workbook that houses our weekly staff meeting agenda items. it plans out months in advance. I am building a macro to automatically copy today's schedule and paste it into a pre-made powerpoint. I had the IF-IfElse-Else macro working, but it has stopped. Can you spot an error?

    Sub CreateStaffTemplate()

    If "B4" = "C20" Then
    Worksheets("Feb").Range("B6:D15").Copy _

    ElseIf "F4" = "C20" Then
    Worksheets("Feb").Range("F6:h15").Copy _

    ElseIf "J4" = "C20" Then
    Worksheets("Feb").Range("J6:L15").Copy _

    ElseIf "N4" = "C20" Then
    Worksheets("Feb").Range("N6:P15").Copy _

    Else

    End If

    End Sub

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: If-ElseIf-Else Macro has stopped working

    Please use CODE tags when posting code.

    You need to remove the underscores from the end of each line, so it should look like:

    Please Login or Register  to view this content.
    If those are supposed to be cell references, then you need to qualify them as ranges, so it then becomes:
    Please Login or Register  to view this content.
    Last edited by Olly; 02-05-2015 at 06:04 PM.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: If-ElseIf-Else Macro has stopped working

    If it is range values that you compare, specify that. If everythng is linked to the Feb-sheet, try:
    Please Login or Register  to view this content.
    Best,
    berlan

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: If-ElseIf-Else Macro has stopped working

    A neater solution may be:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-10-2013
    Location
    Mukilteo, WA
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: If-ElseIf-Else Macro has stopped working

    This worked beautifully. Thanks for your help, and patience with my dumb question!

+ 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 stopped working - please help
    By kellynicolebarrett in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-01-2014, 05:49 AM
  2. Macro stopped working
    By EverettRich in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-21-2013, 03:17 PM
  3. Macro Stopped Working
    By andybason in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2012, 01:20 PM
  4. Macro stopped working.
    By joleen in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-06-2011, 05:37 AM
  5. Excel 2007 : Macro stopped working
    By jaw0001 in forum Excel General
    Replies: 5
    Last Post: 10-13-2010, 07:59 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