+ Reply to Thread
Results 1 to 3 of 3

Copy/pasting only values

Hybrid View

booo Copy/pasting only values 11-05-2010, 04:36 PM
BigBas Re: Copy/pasting only values 11-05-2010, 04:44 PM
booo Re: Copy/pasting only values 11-05-2010, 05:58 PM
  1. #1
    Registered User
    Join Date
    09-29-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    91

    Copy/pasting only values

    I am trying to copy data from one column into another using a for loop. The column from where I copy has formulas in it and am trying to just copy the values. I need just the values and not the formula. This is the code I used.

    Dim i As Integer ' To define the range of cells
    For i = 5 To 297  ' For loop to fill entire range of cells
    If (Cells(i, 16).Value) = 0 Then
    Cells(i, 12).Select
    Selection.Copy
    Cells(i, 16).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Can someone tell me what is going wrong?

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Copy/pasting only values

    The only thing I believe your code is missing is a close to the IF statement and the FOR loop. try this amendment to the code. It resolves your problem and should be more efficient.

    Sub ANALIT()
    
    Dim i As Integer ' To define the range of cells
        Application.ScreenUpdating = False
        For i = 5 To 297  ' For loop to fill entire range of cells
            If (Cells(i, 16).Value) = 0 Then
            Cells(i, 12).Copy
            Cells(i, 16).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
            End If
        Next i
        Application.ScreenUpdating = True
    End Sub

  3. #3
    Registered User
    Join Date
    09-29-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    91

    Re: Copy/pasting only values

    Hello there,

    I tried your code, but it does not seem to be working.

    This is the code I am presently using:

    Dim i As Integer
      For i = 5 To 297
        Cells(i, 16).Select
           If Cells(i, 16).Value = 0 Then
              If Cells(i, 12).Value <> 0 Then
                 Cells(i, 12).Select
                 Selection.Copy
                 Cells(i, 16).Select
                 ActiveCell.PasteSpecial
                 End If
            End If
            Cells(i, 18).Select
           If Cells(i, 18).Value = 0 Then
              If Cells(i, 14).Value <> 0 Then
                 Cells(i, 14).Select
                 Selection.Copy
                 Cells(i, 18).Select
                 ActiveCell.PasteSpecial
               End If
            End If
       Next i
    I am also attaching the worksheet. I am copying values from columns L and N and pasting them in P and R. In P and R,. I need just the values and not the Vlookup function that I used in L and N.

    Thanks/

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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