+ Reply to Thread
Results 1 to 26 of 26

Help with Pasting Value only

  1. #1
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Help with Pasting Value only

    Hello! First of all let me explain that I do not know VBA code - I have pieced together my code from other forum posts and youtube. So when helping, please give me something I can easily type without changing a ton IF POSSIBLE.

    So this code is to help me take some information from 1 worksheet and then send it to another worksheet (in the same workbook) to create a data dump for metric tracking. Here is the code so far:
    ---------------------------------------------------------------------------------------------------------------
    Please Login or Register  to view this content.
    ----------------------------------------------------------------------------------

    The section of the code where I turned the text to red is where I need help. Currently this code works perfectly for what I need except this one line always pastes the formula, and understandably so, but I need it to be value only. In fact, all of them can be value only...if that helps you help me. But this is the one that I need,

    Thank you so much!
    Last edited by vg05; 10-04-2021 at 08:46 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Help with Pasting Value only

    Hello vg05,

    You'll need it in two lines of code as follows:-

    Please Login or Register  to view this content.
    You should now get the idea for the other lines of code.

    I hope that this helps.

    Cheerio,
    vcoolio.

  3. #3
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: Help with Pasting Value only

    Thanks, but I probably should have mentioned that I tried that code already and I get a syntax error when I do.

    Any other suggestions I can try?

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hello ! Try this …


    Removing the useless :

    PHP Code: 
    Private Sub CommandButton1_Click()
            If 
    Sheet1.[A13].Value "" Then MsgBox "You must enter a Part Number before adding to the log": Exit Sub
        With Sheet4
    .Cells(Rows.Count1).End(xlUp)(2)
            .
    Value Sheet1.[E13].Value
            
    .Cells(12).Value Sheet1.[A13].Value
            
    .Cells(14).Resize(, 2).Value Sheet1.[C13:D13].Value
            
    .Cells(16).Value Sheet1.[I13].Value
            
    .Cells(17).Value Sheet1.[T8].Value
            
    .Cells(18).Value Sheet1.[R13].Value
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  5. #5
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: Hello ! Try this …

    Thank you so much!!

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Help with Pasting Value only

    Administrative Note:

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. 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, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then 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

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  7. #7
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: Hello ! Try this …

    Quote Originally Posted by Marc L View Post

    Removing the useless :

    PHP Code: 
    Private Sub CommandButton1_Click()
            If 
    Sheet1.[A13].Value "" Then MsgBox "You must enter a Part Number before adding to the log": Exit Sub
        With Sheet4
    .Cells(Rows.Count1).End(xlUp)(2)
            .
    Value Sheet1.[E13].Value
            
    .Cells(12).Value Sheet1.[A13].Value
            
    .Cells(14).Resize(, 2).Value Sheet1.[C13:D13].Value
            
    .Cells(16).Value Sheet1.[I13].Value
            
    .Cells(17).Value Sheet1.[T8].Value
            
    .Cells(18).Value Sheet1.[R13].Value
        End With
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    I actually have 1 other dilemma that maybe you can help me with. So this code is for 1 row of data. But on my sheet, I can have UP TO 10 rows of data, but more than likely each week I would only use 3-4 rows of data. I think based on your code I am comfortable copying, pasting, and changing the cell values to add additional rows of data into the code; however, what can I type to essentially ignore rows without data? So if I only use 4/10 rows, how do I ignore rows 5-10 without having to constantly edit the code?

    Thanks!

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Help with Pasting Value only

    Code tags first, please, then you can continue. Thanks.

  9. #9
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: Help with Pasting Value only

    Ok its done, can you put my post back so I don't have to type it again now.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Help with Pasting Value only

    Thank you.

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Hello ! Try this …


    First thanks for the rep' !

    Quote Originally Posted by vg05 View Post
    what can I type to essentially ignore rows without data? So if I only use 4/10 rows, how do I ignore rows 5-10 without having to constantly edit the code?
    As it may depend on the worksheet design so the better is you attach your workbook just following the top page yellow banner …

  12. #12
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: Hello ! Try this …

    I've attached the sheet. The tabs to focus on are the "template" and the "data log"

    When you click the button on template, that first row of data moves to the data log. I would like all of the rows of data (if filled in) to transfer over, while ignoring the empty rows.

    Please let me know if you need anymore information from me

    Thank you!
    Attached Files Attached Files

  13. #13
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Another try …


    According to your attachment :

    PHP Code: 
    Private Sub CommandButton1_Click()
      Const 
    8
        Dim L
    &, V(), WR&, C%
            
    Application.CountA([A13:A33]):  If 0 Then MsgBox "You must enter a Part Number before adding to the log": Exit Sub
            ReDim V
    (1 To L1 To N)
            
    = [A35].End(xlUp).Row 1
            W 
    Application.Index(Range("A13:R" L), Evaluate("ROW(1:" 12 ")"), [{5,1,2,3,4,9,18}])
        For 
    1 To UBound(WStep 2
            
    If W(L2) > "" Then R 1: For 1 To NV(RC) = W(- (7), + (6)): Next
        Next
            Sheet4
    .Cells(Rows.Count1).End(xlUp)(2).Resize(RN).Value2 V
    End Sub 
    Last edited by Marc L; 10-04-2021 at 12:06 PM.

  14. #14
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: Another try …

    Quote Originally Posted by Marc L View Post

    According to your attachment :

    PHP Code: 
    Private Sub CommandButton1_Click()
      Const 
    8
        Dim L
    &, V(), WR&, C%
            
    Application.CountA([A13:A33]):  If 0 Then MsgBox "You must enter a Part Number before adding to the log": Exit Sub
            ReDim V
    (1 To L1 To N)
            
    = [A35].End(xlUp).Row 1
            W 
    Application.Index(Range("A13:R" L), Evaluate("ROW(1:" 12 ")"), [{5,1,2,3,4,9,18}])
        For 
    1 To UBound(WStep 2
            
    If W(L2) > "" Then R 1: For 1 To NV(RC) = W(- (7), + (6)): Next
        Next
            Sheet4
    .Cells(Rows.Count1).End(xlUp)(2).Resize(RN).Value2 V
    End Sub 
    Thanks a lot Marc! This does work!

  15. #15
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: Another try …

    Hey Marc, Unfortunately, with this being something new for me at work, I keep getting told to add things, and this newer code I don't quite understand like the old one.

    Here is what I now need to do: I need ANOTHER date to be in column A, and I need to shift the rest of the cells to the right. The date will be the worksheet date, also found in N9. And then also I added a column, the "reason for non-attainment" and I need that to also populate over. I've reattached that sheet. Any way that you could help with this? Also, is there a way that you could define the terms of your code to help me understand?

    Thank you so much!
    Attached Files Attached Files

  16. #16
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Lightbulb Re: Help with Pasting Value only


    So it could be : (v2)

    PHP Code: 
    Private Sub CommandButton1_Click()
      Const 
    8
        Dim L
    &, V(), T$(), WXR&, C%
            
    Application.CountA([A13:A33]):  If 0 Then MsgBox "You must enter a Part Number before adding to the log": Exit Sub
            ReDim V
    (1 To LN), T(1 To L0)
            
    = [A35].End(xlUp).Row 1
            W 
    = [T13:T34]
            
    Application.Index(Range("A13:R" L), Evaluate("ROW(1:" 12 ")"), [{5,1,2,3,4,9,18}])
            
    = [N9].Value2
        
    For 1 To UBound(WStep 2
            
    If W(L2) > "" Then
                R 
    1:       V(R0) = X:       T(R0) = Cells(1220).Text
                
    For 1 To N:  V(RC) = W(- (7), + (6)):  Next
            End 
    If
        
    Next
        With Sheet4
    .Cells(Rows.Count1).End(xlUp)(2).Resize(R1)
            .
    Value2 V
            
    .Columns(16).Value2 T
        End With
    End Sub 
    Last edited by Marc L; 10-05-2021 at 02:29 PM.

  17. #17
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: Help with Pasting Value only

    Thanks! unfortunately, an Error Code right here: (Red Text)
    Please Login or Register  to view this content.

    Edit: Yellow was a bad choice - red is better
    Last edited by vg05; 10-04-2021 at 07:26 PM.

  18. #18
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: Help with Pasting Value only

    I can move the date column (new column A) to a different column (Not A) if it helps to keep the due date column (old column A) where it was....
    Last edited by vg05; 10-04-2021 at 07:32 PM.

  19. #19
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Help with Pasting Value only


    As I well works on my side and as I can't guess anything …

  20. #20
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150
    Ok thank you.

    Since it works on your end, can you save and re attach my sheet with your code on it?

  21. #21
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Help with Pasting Value only


    Attach your workbook with the data where the error raises …

  22. #22
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: Help with Pasting Value only

    Here you go,

    When I click the button on either the template page or the 9.27 page nothing happens, but when I press it from template(2) I get the mismatch error and the debugger shows the issue I highlighted.
    Attached Files Attached Files

  23. #23
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Help with Pasting Value only


    Try the new version just updated in post #16 …

  24. #24
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: Help with Pasting Value only

    Yes! You sir, are a genius. Thank you so much for all of your help. I have tried to give you more rep, but it won't let me.

    I do have 1 last question, and it shouldn't require anymore code or sharing of sheets.

    As I am sure you noticed, my plan is to create a new tab every week to track my clients progress. My client will have access to the sheet as well. Once the week is complete, I would like to "freeze" that week so that nothing can be edited. What I have done so far is protected the sheet and unchecked EVERYTHING. Now, nothing can be edited EXCEPT you can still press the "Add orders to data log" button - is there a way that I can "freeze" that button once I protect the sheet so that it cannot be pressed anymore?

    Thank you!

  25. #25
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Help with Pasting Value only


    After the Dim codeline add a new codeline : If ProtectContents Then Exit Sub

  26. #26
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,528

    Re: Help with Pasting Value only

    My preference for your problem described in Post #1 is
    Please Login or Register  to view this content.
    That problem was solved but just for future.

+ 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. Pasting data into every second row, and also pasting it as a duplicate
    By rhibrown in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-24-2019, 06:04 PM
  2. [SOLVED] Two Totals Pasting to Wrong Column - The rest are pasting correctly
    By CHRISOK in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-20-2018, 05:00 PM
  3. pic pasting
    By kraman183 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-24-2013, 04:20 AM
  4. Replies: 10
    Last Post: 02-09-2010, 05:04 AM
  5. Copy+pasting from Firefox vs Copy+pasting from IE
    By srbloom in forum Excel General
    Replies: 0
    Last Post: 02-02-2009, 05:45 PM
  6. Replies: 1
    Last Post: 08-28-2005, 09:05 AM
  7. [SOLVED] Pasting numbers and formulas without pasting format.
    By Dan in forum Excel General
    Replies: 3
    Last Post: 03-26-2005, 11:06 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