+ Reply to Thread
Results 1 to 6 of 6

For Loop Problem

  1. #1
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    For Loop Problem

    So I have been trying to adapt some code that a kind EF user helped me with and I seem to be having issuing with the new for loop I've created. I'm trying to get the code to multiply the last column in the array with another array one by one but I'm having two issues. It replaces every value in the last column with 24. I've attached the file; am I missing something basic in my code?
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: For Loop Problem

    Try the attached.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: For Loop Problem

    Brilliant! I was just trying to work in the n = n + 1 part but kept getting an out of range. Thank you!

  4. #4
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: For Loop Problem

    Quick question, what is the difference between putting the "." in front of Range and not including it?

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: For Loop Problem

    Since you have more than 1 sheet and if you do not reference the sheet name, you get a funny result. The code assumes you are working on the active sheet( Which one is the active sheet depends on your cursor at any point during running). If you do with and end with, you need to include a dot. This way the code will know which sheet and range you are referring to when you loop through.

  6. #6
    Registered User
    Join Date
    07-02-2013
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: For Loop Problem

    Thank you! I learned something new and crucial today! Thank you very much!

+ 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. Vlookup problem in a loop with cell property and variable cell problem (long title sry)
    By ExcelsiorLux in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-13-2013, 10:38 AM
  2. For Each Loop problem
    By AndrewMac in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-14-2013, 10:26 AM
  3. [SOLVED] Loop inside a loop problem!
    By questionguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2012, 12:54 PM
  4. loop's problem
    By eran3185 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2007, 04:30 AM
  5. Problem adding charts using Do-Loop Until loop
    By Chris Bromley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2005, 09:06 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