View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach Otto Moehrbach is offline
external usenet poster
 
Posts: 1,090
Default For Next Loop...Copying from a cell one column to another...

This little macro should do what you want. HTH Otto
Sub LoopCol5()
Dim RngCol5 As Range
Dim i As Range
Dim c As Long
Set RngCol5 = Range("E2", Range("E" & Rows.Count).End(xlUp))
For Each i In RngCol5
Select Case i.Value
Case "Person": c = 5
Case "Place": c = 6
Case "Thing": c = 7
Case Else: GoTo NextCell
End Select
Cells(i.Row, 4).Value = Cells(i.Row, c).Value
NextCell:
Next i
End Sub

"bourbon84" wrote in message
...
Hi all. I am brand new to VBA, and am fumbling my way thru this. Any
help
is appreciated. I have one worksheet with several thousand rows, and
about
10 columns. I need to loop thru all the rows in column 5 to see if each
cell
meets a certain criteria (is the text there = "Person" or "Place" or
"Thing"?)

If R2, C5 = "Person", then copy "Person" to R2, C4.
If R2, C5 = "Place", then copy whatever is in R2, C6 to R2, C4
If R2, C5 = "Thing", then copy whatever is in R2, C7 to R2, C4

You'd think, with all the Excel help pages and example code out there,
that
I could figure this out. But apparently, I can't.