+ Reply to Thread
Results 1 to 9 of 9

automate Copy and paste into static value

  1. #1
    Registered User
    Join Date
    12-09-2018
    Location
    Montreal
    MS-Off Ver
    2017
    Posts
    28

    automate Copy and paste into static value

    Hi there,

    I can't find a way with formula to copy source cell value to target cell and make it static. (yes, can manually click and click to paste value only, but how to automate it)
    Anyone know if there is a way to do it?
    I read some macro or script that could automate the copy and paste, but how to make it static in target cell?

    thanks in advance

    txt007
    Attached Files Attached Files

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: automate Copy and paste into static value

    EDIT : posted in wrong post. Sorry
    Happy with my advice? Click on the * reputation button below

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: automate Copy and paste into static value

    To Sheet1 code module
    Please Login or Register  to view this content.

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: automate Copy and paste into static value

    PHP Code: 
    Private Sub Worksheet_Change(ByVal Target As Range)
    If 
    Not Intersect(TargetRange("B2")) Is Nothing Then
        
    For Each cell In Range("C3:C10000")
            If 
    cell "" Then
            cell
    .Value Range("B2").Value
            
    Exit For
            
    End If
        
    Next
    End 
    If
    End Sub 
    Attached Files Attached Files
    Quang PT

  5. #5
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: automate Copy and paste into static value

    Quote Originally Posted by jindon View Post
    To Sheet1 code module
    Hi Jindon,
    Yours and mine, both do not work, if B2 has formula. For instant, B2=A1+B1
    If A1 or B1 changed, B2 change value, but worksheetchange evens could not fire it.
    Any idea?

  6. #6
    Registered User
    Join Date
    12-09-2018
    Location
    Montreal
    MS-Off Ver
    2017
    Posts
    28

    Re: automate Copy and paste into static value

    Hi Jindon and Bebo,
    thanks a lot for your help. Am quite beginner in VBA, have watched youtube video for vba beginners, but still can figure out how to use your code.
    I download the book1(1).xlsx ofr Bebo, but there is nothing change inside (no VBA module or macro)


    txt007

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: automate Copy and paste into static value

    Try the attached.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    12-09-2018
    Location
    Montreal
    MS-Off Ver
    2017
    Posts
    28

    Re: automate Copy and paste into static value

    Actually, I am doing a workbook to calculate golf handicap index.
    Everything works, except i can't find a way to sort out the Exceptional Scores Reduction calculation.
    The Exception Scores Reduction is -1 if player gets a differential (diff) 7-10 better than his/her HI at the time playing the game (today HI), and -2 if it's >10 points better. And the ESR is cumulative to the previous 20 scores, if any.

    So there are 2 difficulties that stuck me here (please at the Latest20scores sheet):
    1) the today HI will be changing after every game (so i was thinking to copy static to a target cell and use static value in the target cell to calculate for the ESR. I can't figure how to automate copy and paste value into static)
    2) the ESR -1 or -2 will be moving down the row correspondingly when there will be new score adding in (score added in Scores sheet will automatically be added on the first row of the 20 row diff calculation (row 13 in the sheet) to calculate the next diff and HI. So, 19/11/2021, player had a score of 84, which gave a Diff of 7-10 better than the HI at the time he played that game, so -1, and on 20/11/2021, he got a score of 75, which again gave a Diff >10 points better than the HI at the time he was playing.

    I think if I could make Excel automatically copy the Today HI and paste it into static value in a way like I copy it MANUALLY into a target cell (highlighted in yellow), then I could use them to calculate the ESR.
    Wonder if anyone has better idea?

    *Note that I hide all other players and show one player

    thanks a bunch
    txt007
    Last edited by TXT007; 11-24-2021 at 11:58 PM.

  9. #9
    Registered User
    Join Date
    12-09-2018
    Location
    Montreal
    MS-Off Ver
    2017
    Posts
    28

    Re: automate Copy and paste into static value

    Hi Jindon,
    it looks great! I will try to adapt your vba for my workbook to calculate the ESR.
    thanks a lot
    txt007

+ 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] Using VBA to automate copy/paste on new Sheet
    By mdolinger in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-12-2016, 09:18 AM
  2. Copy static range and paste at new cell. Macro VBA
    By ECEUK in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-02-2015, 07:47 AM
  3. Automate repititive copy and paste
    By Raury in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-29-2014, 12:53 PM
  4. Copy and Paste a range based on a cell value that is not static
    By JmundleBofA in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-10-2014, 03:25 PM
  5. How to automate copy paste
    By alyasch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-13-2013, 09:36 AM
  6. Automate copy and paste and copy and paste back to excel
    By Bmw318be in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2013, 05:42 AM
  7. Automate copy and paste and copy and paste back to excel
    By Bmw318be in forum Access Tables & Databases
    Replies: 0
    Last Post: 02-23-2013, 05:42 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