+ Reply to Thread
Results 1 to 3 of 3

Copy cell value to another cell with variable number of iterations

Hybrid View

  1. #1
    Registered User
    Join Date
    08-03-2012
    Location
    Netherlands-Venlo
    MS-Off Ver
    Excel 2010
    Posts
    9

    Wink Copy cell value to another cell with variable number of iterations

    Hello,

    Attached file column A shows 24 values which are entered by the user. Cell E3 calculates a random value every time there is a change in the worksheet. This is an array function. What I want is that every random value is calculated as much as the number of iterations entered in Cell E1. Every random value must be placed from Cell E3 in column G, starting with Cell G2. Following random value calculated from Cell E3 must be placed in Cell G3 etc. This as much as the number of iterations enterd by the user. I tried a couple of times in Vba, but I need some advise! Here is a start from my code.

    Thanks in advance!

    Cheers, Bart

    Sub Randomnumber()
    Range("E5").Name = "Source"
    Range("G2").Select
    ActiveCell = Destination
    
    Iterations = 5000
    
    
    Counter = 1
    Do While Counter <= Iterations
            Range("Source").Select
            Selection.Copy
            Range("Destination").Select
            Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
            Application.CutCopyMode = False
            ActiveCell.Offset(1, 0).Select
            Counter = Counter + 1
    Loop
    
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Copy cell value to another cell with variable number of iterations

    You may try this to see if you get the desired output.
    Sub Randomnumber()
    Application.ScreenUpdating = False
    Range("E5").Name = "Source"
    Columns("G").Clear
    Iteraties = Range("E1").Value
    teller = 1               'Variabele "Teller" inbouwen en initieel vullen met 1
    Do While teller <= Iteraties                                'Voer deze lus uit totdat de variabele "Teller" 30 bereikt
            Range("Source").Copy
            Range("Destination").Offset(teller - 1, 0).PasteSpecial (xlValues)
            teller = teller + 1
    Loop
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    End Sub
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    08-03-2012
    Location
    Netherlands-Venlo
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Copy cell value to another cell with variable number of iterations

    Thanks! That was what I needed!!!!

+ 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] Find a variable text string in a cell and copy this to another cell
    By Timmy22 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-02-2014, 09:50 AM
  2. Replies: 10
    Last Post: 02-12-2014, 04:14 AM
  3. Replies: 2
    Last Post: 07-24-2012, 11:47 AM
  4. Replies: 2
    Last Post: 05-30-2012, 05:02 PM
  5. Cell Iterations???
    By jkresch in forum Excel General
    Replies: 5
    Last Post: 04-21-2009, 06:59 PM

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