+ Reply to Thread
Results 1 to 2 of 2

Repetition code with variables

  1. #1
    Registered User
    Join Date
    10-10-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    75

    Repetition code with variables

    Morning Folks

    Could do with some help on this one...

    I have the following code...

    Discount = Range("Prelimdiscount").Value
    total = Range("prelimtotal").Value
    finalprice = total - (total * Discount)
    Range("prelimtotal").Value = finalprice

    ...which runs at the press of a button embed into the spreadsheet.

    The thing is i need the same code to run on about 10-15 different ranges, all with different names (prelimdisount etc.)

    is there anyway of repeating this code without having to type it out 10-15 times for each individual name range?

    I could be being very lazy here, so please tell me!!

    TVM

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Repetition code with variables

    Not unless there's logic in how the cells are located, consistently so many apart etc.

    There's also no need to assign the values to variables:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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