How to search a column and return the value in the next column with specific value

I have an Excel worksheet that contains columns and multiple sheets. I want to copy column A from Sheet1 to Sheet2. Then once I've copied column A, I want column B from Sheet2 to have a specific value (in this case, "D") adjacent to each filled cell in A. I am only stuck with the code below.

Example:

Sheet1 contains:

Column A      B      C
       Arthur 1      34
       Bertha 2      35

Sheet2 must have:

Column A      B
       Arthur "D"
       Bertha "D"

Stuck with code:

Worksheets("Sheet1").Columns("A").Copy ActiveCell.Columns("A:A").Columns("A")

Answers


Is this what you are trying?

Option Explicit

Sub Sample()
    Dim wsI As Worksheet, wsO As Worksheet
    Dim lRow As Long

    Set wsI = Sheets("Sheet1")
    Set wsO = Sheets("Sheet2")

    wsI.Columns(1).Copy wsO.Columns(1)

    lRow = wsO.Range("A" & wsO.Rows.Count).End(xlUp).Row

    wsO.Range("B1:B" & lRow).Value = "D"
End Sub

Need Your Help

DurandalJS and composing Child Views with Parameters

javascript durandal durandal-2.0

I'm having some difficulty transitioning from Knockout's template binding to the Durandal compose binding.

d3 tree layout - force child nodes to use available space

javascript tree d3.js visualization

I have a tree-based layout using d3, based on the collapsable tree layout example here.