macro terminates with no error

  • Thread starter Thread starter pH7
  • Start date Start date
P

pH7

The following macro just terminates after the line that say
"rng.EntireColumn.Hidden = False". That line seems to execut
correctly. There is no error of any kind displayed. Any idea why?

Code
-------------------

Sub name_fixup(old_name As String, new_name As String)
Dim rng As Range
Set rng = ActiveSheet.Range("H:L")
rng.EntireColumn.Hidden = False

Set c = rng.Find(old_name, LookIn:=xlValues, LookAt:=xlWhole)
While Not c Is Nothing
c.Value = new_name
Set c = rng.FindNext()
Wend
rng.EntireColumn.Hidden = True
End Sub

-------------------

The reason I am trying to do the unhide is that the Find fails if th
columns are hidden. Is there some way to make the Find search in hidde
columns? (Then I won't have to use the statements that are causin
problems.
 
Sub tester2()
name_fixup "house", "cat"
End Sub


Sub name_fixup(old_name As String, new_name As String)
Dim rng As Range
Set rng = ActiveSheet.Range("H:L")
rng.EntireColumn.Hidden = False

Set c = rng.Find(old_name, LookIn:=xlValues, LookAt:=xlWhole)
While Not c Is Nothing
c.Value = new_name
Set c = rng.FindNext()
Wend
rng.EntireColumn.Hidden = True
End Sub



Worked fine for me. I didn't alter you code.
 
I found the answer to my second question and therefore the first proble
went away. Sorry, I didn't think to search for that first. If anyon
knows the answer to the first question, it would still be of interes
because I have had that sort of thing happen in other situations a
well
 
The code works fine, so there was no reason to ask either question.
 

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