View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Home Work Help Excel VBA

Looks like you pretty much have it:

Dim OldRegion
OldRegion = Range("C2").Value
Dim NewRegion
NewRegion = Range("D21").Value
Application.StatusBar = "Retrieving Data on " & NewRegion
Dim cell as Range
for each cell in Range("A1:F19")
if lcase(cell.Value) = lcase(oldregion) then
cell.Value = newregion
end if
Next

Application.StatusBar = False


If C2 and D21 contain numbers then

for each cell in Range("A1:F19")
if cell.Value = oldregion then
cell.Value = newregion
end if
Next

note that you will change the current value of C2

--
Regards,
Tom Ogilvy



You could also to the replace by using he replace command (which you can get
the format for by turning on the macro recorder and doing it manually).

--
Regards,
Tom Ogilvy


"not very bright" wrote in message
ups.com...
I am not sure if anyone can help quick enough, but I need some help for
some extra credit due tomorrow morning. I do not know any thing in
excel vba so if you can dumb it down some that would be great.

Here is what I have to do:

1. create a variable named "OldRegion" and set it to cell c2
2. create a variable named "NewRegion" and set it to cell d21
3. change the text of the status bar to "retriveving data on new...,"
where NewRegion is the value of the NewRegion variable.
4. Replace all occurences of "OldRegion" with "NewRegion" in cell range
A1:F19
5. Set the value of status bar back to false.


And here is what I have, but of course it's not working

Dim OldRegion
OldRegion = Range("C2").Value
Dim NewRegion
NewRegion = Range("D21").Value
Application.StatusBar = "Retrieving Data on NewRegion"

Application.StatusBar = False


Any help would be great and my parents would be greatfull also...Thanks