Results 1 to 3 of 3

copying and pasting cell values

Threaded View

  1. #1
    Registered User
    Join Date
    05-21-2011
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    39

    copying and pasting cell values

    Hi everyone!

    I've got the following code which is meant to find cells with no values, colour the cells in, and then replace the missing value with the average of that column. the average is located in a different sheet

    Sub Outliers()
    
    Dim i, j, row, col As Integer
    
    ' Prompting messages
    col = Application.InputBox _
                 (Prompt:="Please enter the number of rows ", _
                   Title:="Row Number", Type:=1)
    row = Application.InputBox _
        (Prompt:="Please enter the number of colums ", _
            Title:="Colum Number", Type:=1)
    
    For i = 1 To row
        
         For j = 1 To col
        
            If IsEmpty(ActiveCell) = True Then
    
    'Copy cell value and paste into cell with missing value
                
     Sheets("Part1DATA").Select
                Range("j" & "4").Select
                Selection.Copy
                Sheets("TrainingData").Select
                Range("j" & "i").Select
                Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                :=False, Transpose:=False
    
      'Make the cell Red
        
                With Selection.Interior     
                    .Pattern = xlSolid
                    .PatternColorIndex = xlAutomatic
                    .Color = 8420607
                    .TintAndShade = 0
                    .PatternTintAndShade = 0
                End With
           
            End If
    'Move one row down
            ActiveCell.Offset(1, 0).Select 
            
        Next j
    'Move up to the top of the table and across
        ActiveCell.Offset(-col, 1).Select 
        
    Next i
    It throws error 400. However, I have the same code (MissingValues), which colours it all in red, as shown on the file submitted.

    The code will later be used to more or less the same extent, except for, it will search for outliers (based on outlier limit) and colouring in the outliers in yellow (hence the name of the sub)

    Much appreciate any help!

    Kurifodo
    Attached Files Attached Files
    Last edited by kurifodo; 05-22-2011 at 01:55 PM.

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