Results 1 to 2 of 2

Thread: [RESOLVED] Enter a value and copy / paste it to all cells in a column where column A has a value

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2012
    Posts
    90

    Resolved [RESOLVED] Enter a value and copy / paste it to all cells in a column where column A has a value

    Hi

    I need to copy a cell value down into all cells in a column where there is a value in column A. So if I enter 'Yes' in cell C2 and there are values in A2 to A300 then I want 'Yes' to be copied from C2 to C300. Could be that the next time I run the code there are 5000 values so I can't hardcode the range to copy down to.

    Thanks for any suggestions.

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Enter a value and copy / paste it to all cells in a column where column A has a v

    This code will find the last filled cell in column A and then copy any cells in A to C (note: doesn't address "entering YES in C2"):

    Code:
    Sub copyAllWithValsInA()
        Dim lastRow As Long
        Dim i As Long
        
        lastRow = Range("a" & Rows.Count).End(xlUp).Row
        
        For i = 2 To lastRow
            If Range("a" & i).Value <> "" Then
                Range("c" & i).Value = Range("a" & i).Value
            End If
        Next i
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width