Search & Replace

  • Thread starter Thread starter John Keturi
  • Start date Start date
J

John Keturi

I have a Calender worksheet, I need the macro to search row 1 (days
Mon-Fri), find only the Fridays, then search down the column until it finds
a name (John), then put "OK" into the corresponding cell? I wrote one where
searches each row & column by using "next". However, its not changing the
corresponding cell value.
 
Sub Macro1()
'
' Macro1 Macro
'
Sheets("data").Select
' count the number of days (in row 1) and the number
'of rows of data (in row 2 on)
ndays = WorksheetFunction.CountA(Range("a1:ia1"))
nRows = WorksheetFunction.CountA(Range("a1:a1000"))
For i = 1 To ndays
If Cells(1, i).Value <> "Fri" Then GoTo nexti
For j = 2 To nRows
If Cells(j, i).Value = "John" Then Cells(j, i).Value = "OK"
Next j
nexti:
Next i
'
End Sub


John
 
Charles, no, and since I am still learning vba, can you
enlighten me as to the advantage of doing so vs my specifc
cell reference?

John
 
John,

I ran your code and it replaced "john" with Ok.
As to why when you run your end of it doesn't work I can't really say
why its not working. If you want send your worksheet to me at
(e-mail address removed) and I'll look it over.

Charles
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top