+ Reply to Thread
Results 1 to 2 of 2

Debugging my macro

  1. #1
    Registered User
    Join Date
    02-22-2019
    Location
    Columbia, SC
    MS-Off Ver
    MS Office 2016 for Mac
    Posts
    1

    Debugging my macro

    Hi, I am trying to debug a macro that was given to me and change the cells being multiplied from 1-8 to 2-9. I am very new to coding macros so I am unsure what to do. Currently, the code is as follows:

    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 02-22-2019 at 12:49 PM.

  2. #2
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 2209 64-bit
    Posts
    21,647

    Re: Debugging my macro

    The code is a bit messy but let me give you some comments:

    Your Dim statement creates two Variants and an Integer. I'll bet you expect it to create three Integers. This does not cause your code to fail but is a programming error. You must specify the type for each variable even if they are on the same Dim statement.

    I am guessing your cells contains values, not formulas. But you are using FormulaR1C1 to retrieve and set values. Again, this is not causing the code to fail but is a programming error. I suggest using Value instead.

    It is not necessary to Select a cell to refer to it.

    I do not see anything in your code that does anything from 1-8. It does have a loop from 1-9. You'll have to be more specific about what you're talking about there.

    I don't see the need for intermediate variable K. K will always be the same as I.

    This seems to grab a value in the cell to the right of the current selection, and use it to multiply time the rows numbers in cells D1:D9 to set the values in those cells. Cells C1:C9 get the row numbers as values.

    Here is how I would rewrite it. Hopefully this makes it clean enough so you can easily see how to change what you want to change:
    Please Login or Register  to view this content.
    Jeff
    | | |?| |?| |?| |?| | |:| | |?| |?|
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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 not working as expected, need someone good at debugging macro's
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 12-23-2015, 09:40 AM
  2. Help debugging Macro
    By AstToTheRegionalMGR in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-13-2015, 02:06 PM
  3. [SOLVED] Help debugging macro
    By kellynicolebarrett in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-16-2014, 09:17 AM
  4. [SOLVED] Debugging a macro
    By jharaldson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-07-2013, 01:52 PM
  5. [SOLVED] Macro debugging
    By VelvetRevolver84 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-01-2013, 06:14 PM
  6. Help please in debugging this macro
    By sungen99 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-23-2006, 11:45 AM
  7. Debugging macro
    By annep in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-20-2006, 06:18 PM

Tags for this Thread

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