+ Reply to Thread
Results 1 to 5 of 5

Paste Values from Range

  1. #1
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2003
    Posts
    31

    Paste Values from Range

    Hi

    I was able to get help from another forum member for this code. It gets ranges from different worksheets and specific cells and brings them back to one master worksheet. I was wondering how to modify the code so that the ranges come back to the master sheet as paste special as values. Here is the code so far

    Sub PullData()

    Dim ws As Worksheet: Set ws = Sheets("Master")
    Dim wksht As Worksheet
    Dim lMasterLR As Long, lwkshtLR1 As Long, lwkshtLR2 As Long
    Dim strAccount As String

    On Error GoTo ErrHandler

    Application.ScreenUpdating = False

    For Each wksht In Worksheets
    If wksht.Name <> "Master" Then
    lMasterLR = ws.Range("B" & Rows.Count).End(xlUp).Row
    strAccount = wksht.Range("C8").Value
    If wksht.Range("B23").Value <> "" Then
    lwkshtLR1 = wksht.Range("B" & Rows.Count).End(xlUp).Row
    wksht.Range("B23:B" & lwkshtLR1).Copy Destination:=ws.Range("B" & lMasterLR).Offset(1, 0)
    ws.Range("C" & lMasterLR + 1).Value = strAccount
    ws.Range("C" & lMasterLR + 1, "D" & ws.Range("B" & Rows.Count).End(xlUp).Row).FillDown
    End If
    If wksht.Range("F23").Value <> "" Then
    lwkshtLR2 = wksht.Range("F" & Rows.Count).End(xlUp).Row
    wksht.Range("F23:F" & lwkshtLR2).Copy Destination:=ws.Range("I" & lMasterLR).Offset(1, 0)
    End If
    End If
    Next wksht

    Application.ScreenUpdating = True

    Debug.Print "Procedure Completed Successfully"

    Exit Sub

    ErrHandler:
    Debug.Print "There has been a critical error."
    Application.ScreenUpdating = True

    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    09-01-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    324

    Re: Paste Values from Range

    Hello to paste only values in your code, update with below:

    Change the lines near the end:

    Please Login or Register  to view this content.

    to this

    Please Login or Register  to view this content.

    and

    Please Login or Register  to view this content.

    to this

    Please Login or Register  to view this content.
    Last edited by playaller; 05-16-2014 at 03:55 PM.


    Shelton A.
    If Helpful, Add Reputaion!

  3. #3
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Paste Values from Range

    I tried it, and it only brought back the first range, and it still didn't paste as values.

  4. #4
    Registered User
    Join Date
    05-15-2014
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Paste Values from Range

    Never mind. I was tweaking it incorrectly. IT WORKED! Thank you!

  5. #5
    Valued Forum Contributor
    Join Date
    09-01-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    324

    Re: Paste Values from Range

    You're more than welcome! Glad I could help.

+ 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] Copy and paste range as values to specific sheet/range
    By lukestkd in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-06-2014, 09:48 PM
  2. Paste as values macro where range(A1:row(A1)+Sum(D1:D5))?
    By Dwexdwex in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2013, 12:41 PM
  3. copy and paste a range of values
    By strucad in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-13-2012, 09:56 AM
  4. Paste Values Without Selecting the destination range
    By joatm0n in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2012, 05:59 PM
  5. How to use VBA to paste formula values to a range?
    By skysurfer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-09-2010, 03:01 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