+ Reply to Thread
Results 1 to 3 of 3

Taking values from cells for use in Macros

  1. #1
    dziw
    Guest

    Taking values from cells for use in Macros

    I am writing a for loop in a macro to loop as shown

    For i = 1 To #
    Perform Task
    Next i
    End

    In the worksheet i am using this macro i want to specify the number of iterations for the loop to perform by placing an integer value in a cell, i then want the value i put in the cell to replace the # in the macro, what do i put in the code instead of the # to do this??

    Thankyou in advance

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Hi. Please read forum rules before posting:

    http://www.excelforum.com/showthread.php?t=591596

    You must wrap your code using the # symbol located in the reply window.

    To answer your question, you need to assign a variable to the applicable cell. For example, assume you are using cell A1:
    Please Login or Register  to view this content.
    HTH

    Jason

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,418
    Use the Value property. worksheet(1).cells(1,1).value

+ 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