Results 1 to 3 of 3

Adding Paste Special Values to Macro

Threaded View

newyorkhoosier Adding Paste Special Values... 11-30-2012, 02:00 AM
patel45 Re: Adding Paste Special... 11-30-2012, 03:33 AM
newyorkhoosier Re: Adding Paste Special... 11-30-2012, 03:38 AM
  1. #1
    Registered User
    Join Date
    11-30-2012
    Location
    NYC, NY
    MS-Off Ver
    Excel 2010
    Posts
    2

    Adding Paste Special Values to Macro

    I have a macro that I'm using to copy a column of numbers then paste the column on a separate sheet. The source column will change every month, so the target column is being pasted to the immediate right of the previous paste.

    My problem is I don't know how to change the Macro so that it will paste special values from the source column.

    Thanks in advance for any assistance.

    Here is my code:

    Sub HistoricalData()
    Dim RI As Worksheet, Yes As Worksheet, SourceCol As Integer, SourceCells As Range
    
    
    On Error GoTo Err_Handler
    
    
    Set SourceSht = ThisWorkbook.Sheets("RI")
    
    
    Set TargetSht = ThisWorkbook.Sheets("Yes")
    
    
    Set SourceCells = SourceSht.Range("K10:K17" & SourceSht.Range("K17").End(xlUp).Row)
    
    
    If TargetSht.Range("A1").Value = "" Then
        SourceCol = 1
    ElseIf TargetSht.Range("IV1").Value <> "" Then
        MsgBox "There are no more columns available in the sheet " & TargetSht.Name, vbCritical, "No More Data Can Be Copied"
        Exit Sub
    Else
        SourceCol = TargetSht.Range("IV1").End(xlToLeft).Column + 1
    End If
    TargetSht.Cells(1, SourceCol).Value = Format(Date, "MM/YYYY")
    
    SourceCells.Copy TargetSht.Cells(2, SourceCol)
    
    MsgBox "Data copied successfully!", vbInformation, "Process Complete"
    
    Exit Sub 
    Err_Handler:
    MsgBox "The following error occured:" & vbLf & "Error #: " & Err.Number & vbLf & "Description: " & Err.Description, _
            vbCritical, "An Error Has Occured", Err.HelpFile, Err.HelpContext
    
    
    End Sub
    Last edited by newyorkhoosier; 11-30-2012 at 02:57 AM. Reason: incorrect format

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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