PDA

View Full Version : copy cell content depending on value



jen122
01-20-2007, 09:28 AM
Hi,

There are 3 columns. If column A has the name "X", I want the content of column B to be copied to column C, for the whole sheet.

How can I do this.

Thanks

tpoynton
01-20-2007, 09:45 AM
=IF(A2="X", B2, "")

Assuming your data start in row 2. Paste this formula into column C row 2 and copy down.

jen122
01-20-2007, 10:13 AM
Dim wkssht As Worksheet
Dim range1, r As Range
Dim fCell, lCell As Range
Set wkssht = Workbooks("book1.xls").Worksheets("Folder")
Set fCell = wkssht.Cells(1, 10)
Set lCell = wkssht.Cells(1500, 10).End(xlUp)
Set range1 = wkssht.Range(fCell, lCell)
For Each r In range1
With r
If .Value = "X" Then
.Offset(0, 1) =

Bob Phillips
01-20-2007, 10:19 AM
Dim wkssht As Worksheet
Dim range1, r As Range
Dim fCell, lCell As Range
Set wkssht = Workbooks("book1.xls").Worksheets("Folder")
Set fCell = wkssht.Cells(1, 10)
Set lCell = wkssht.Cells(1500, 10).End(xlUp)
Set range1 = wkssht.Range(fCell, lCell)
For Each r In range1
With r
If .Value = "X" Then
.Offset(0, 1).Copy .Offset(0, 2)
End If
End With

jen122
01-20-2007, 10:28 AM
thanks worked great