Excel Macro Problem - search and replace cells

djtaverner
04-13-2006, 11:55 AM
Hi

Column 8 in my worksheet has names.

I want the name to change to Bob when the cell in column 4 has OU-BW in it AND the cell in column 8 has content ie, a name in it

As coded below

Sub MacroReplaceName()
'
' MacroChangeToOU Macro
' Macro recorded 13/04/2006 by Registered User
'
Dim Count

Count = 1

ThisWorkbook.Worksheets("reporting").Select
Do While Count < Range("H65536").End(xlUp).Row ' finds last row
If Cells(Count, 4).Value = "OU-BW" And Cells(Count, 8).Value <> "" Then
Cells(Count, 8).Value = "Bob"
Else
Count = Count + 1
End If

Loop
End Sub

A cell near the top of the sheet I can see is replaced properly but the Excel program crashes.

Any suggestions??

tinyjack
04-13-2006, 12:16 PM
Count is not being changed if you make the swap, take the increment out of the IF and put it just before the Loop

TJ

djtaverner
04-13-2006, 12:53 PM
i feel stupid,

cheers thay worked

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum