+ Reply to Thread
Results 1 to 9 of 9

Macro - debug error

Hybrid View

emptycucumber Macro - debug error 05-18-2009, 09:55 PM
emptycucumber Re: Macro - debug error 05-19-2009, 01:37 AM
Trebor76 Re: Macro - debug error 05-19-2009, 07:03 AM
Trebor76 Re: Macro - debug error 05-18-2009, 10:33 PM
emptycucumber Re: Macro - debug error 05-18-2009, 11:45 PM
protonLeah Re: Macro - debug error 05-19-2009, 12:06 AM
Trebor76 Re: Macro - debug error 05-19-2009, 12:21 AM
emptycucumber Re: Macro - debug error 05-19-2009, 12:35 AM
Trebor76 Re: Macro - debug error 05-19-2009, 12:55 AM
  1. #1
    Registered User
    Join Date
    05-18-2009
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    34

    Macro - debug error

    Any help would be appreciated

    Sub Shack()
    ' Shack Macro
        Range("$M$8").Select
        ActiveCell.FormulaR1C1 = "=$B$3+$E$8" (When I hit debug, this line was highlighted.)
        Range("$M$8").Select
        Selection.Copy
        Range("$E$8").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False
        Range("$M$8").Select
        Selection.ClearContents
        Range("$M$3").Select
        ActiveCell.FormulaR1C1 = "=$E$3-$B$3"
        Range("$M$3").Select
        Selection.Copy
        Range("$E$3").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        Application.CutCopyMode = False
        Range("$M$3").Select
        Selection.ClearContents
        Range("$E$8").Select
    End Sub
    Last edited by emptycucumber; 05-18-2009 at 10:05 PM.

  2. #2
    Registered User
    Join Date
    05-18-2009
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Macro - debug error

    How do I include a logical value?

    Sub Shipping_Company()
    Range("shipping").Value = Evaluate("=shipping+1")
    Range("undeveloped").Value = Evaluate("=undeveloped-4")
    End Sub
    IF undeveloped=4 Range("undeveloped").Value = Evaluate("=undeveloped-4")
    IF undeveloped=3 Range("undeveloped").Value = Evaluate("=undeveloped-3")

    etc etc, of course I'd clean up the code. I just need to know how to structure it.


  3. #3
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Macro - debug error

    Hi there,

    You should really start a new thread for each separate query.

    That said, I'm not sure how many arguments you're referring to when you say "etc etc" but I think the following may be what you're after:

    Sub Macro1()
    
        Select Case Range("undeveloped").Value
            Case 3
                Range("undeveloped").Value = Evaluate("=undeveloped-3")
            Case 4
                Range("undeveloped").Value = Evaluate("=undeveloped-4")
        End Select
            
    End Sub
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Macro - debug error

    Hi emptycucumber,

    Welcome to the forum and thanks for fixing up your post.

    Post back re how the following goes:

    Sub Shack()
        
        Range("E8").Value = Evaluate("=$B$3+$E$8")
        Range("E3").Value = Evaluate("=$E$3-$B$3")
        
        Range("E8").Select
        
    End Sub
    HTH

    Robert
    Last edited by Trebor76; 05-18-2009 at 10:39 PM.

  5. #5
    Registered User
    Join Date
    05-18-2009
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Macro - debug error

    OMG!!! AMAZING

    Thank you so much. You cleaned up the code so nicely too.

    Works perfect!

    QUESTION: How would I go about writing a code to delete the contents of a cell?
    Last edited by emptycucumber; 05-18-2009 at 11:54 PM.

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,953

    Re: Macro - debug error

    To fix the original code:
    ActiveCell.FormulaR1C1 = "R[5]C[-11]+RC[-8]
    where the numbers in [] are the offsets from the selected cell.
    & RC[-8] = R[]C[-8]; references a cell in the same row as the selected cell.
    Last edited by protonLeah; 05-19-2009 at 12:24 AM.
    Ben Van Johnson

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Macro - debug error

    Hi emptycucumber,

    Glad it worked

    The following will delete all contents within cell A5...

    Range("A5").ClearContents
    ...while the following will delete all contents from the range A5:B10:

    Range("A5:B10").ClearContents
    HTH

    Robert

  8. #8
    Registered User
    Join Date
    05-18-2009
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Macro - debug error

    Works!

    Hmm, actually I would prefer to make the cell value "0". How would I do that?

    Range("D4").Value something?
    LOL! I was about to ask you that question, but I figured it out on my own.

    I'm a beginner, so excuse me Thanks for the help!
    Last edited by emptycucumber; 05-19-2009 at 01:02 AM.

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Macro - debug error

    You're welcome

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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