+ Reply to Thread
Results 1 to 2 of 2

Simple Copy & Paste for ranges ,but with random values

  1. #1
    Registered User
    Join Date
    01-18-2015
    Location
    madrid
    MS-Off Ver
    2011
    Posts
    1

    Simple Copy & Paste for ranges ,but with random values

    I cannt understand, why my excel script does not work anymore.. I need to do simple copy Paste function,
    First, I have 1 value (Mean) which is generated and it changes randomly after any action (Very important point!)
    So , I need a kind of "simulation", means to copy the value and put it in another worksheet, after that the excel is refreshing automatically and I get a new mean-value..
    This process should be repeated 1000 times. It means i will have 1000 different values at the end, because of random changes of my mean-value
    I have a script, which works perfect for this purpose.

    Dim i AsInteger
    Sheets("Worksheet2").Select
    Cells(4,23).Select
    Selection.Copy
    '
    Sheets("Worksheet3").Select
    For i =1To1000
    Cells(1+ i,1).Paste
    Special Paste:=xlPasteValues
    Next i
    '
    EndSubNow,

    I have not only one cell (my mean-value) but two! ( median from the same data)
    It means, now it should copy two cells simultaneously (range) and paste than in the new worksheet, in the new range. So, it is the same process, like in my script, but with two cells
    a kind of this..

    Dim i AsInteger
    Sheets("Worksheet3").Select
    Range("W4:X4").Select
    Selection.Copy
    '
    Sheets("Workshit4").Select
    For i =1 To 100 Range("A2:B2"&1+ i).PasteSpecial Paste:=xlPasteValues
    Application.CalculateFull
    Next i
    '
    EndSub

    I tried to do it with range() BUT!!! it doesnt refresh my mean and median values anymore ... or something else... so I get 1000 times the SAME!! value after the script running.
    I can not understand, what is his problem. Why in first case it works perfect, and if I do the same task with range, it seems to copy the same value about 1000 times, but not refreshing or changing it.
    pleas, I hope, anybody could help me
    thank you very much!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Simple Copy & Paste for ranges ,but with random values

    Hi and welcome to the forum. Unfortunately your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ 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. Copy and paste special values for non contiguous ranges
    By ndelta34 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2014, 06:51 AM
  2. [SOLVED] I need to set ranges for Unique values, then from those ranges pick random cells...
    By Darth269 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-21-2014, 04:45 PM
  3. how to get a simple macro to copy and paste values only
    By sumesh56 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2014, 11:03 PM
  4. [SOLVED] Copy and paste ranges of cells based on values in column A
    By ajk1789 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2014, 02:04 AM
  5. Set Multiple (non-continous) ranges for easy Copy then paste values
    By ron2k_1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2011, 08:48 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