Find word throughout range and capitalize

Pjam

Board Regular
Joined
Jun 4, 2008
Messages
139
Im looking to find the word sample throughout my spreadsheet its, scattered every where, and i need to change sample to Sample,
and idea?

the range is a1:z500
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Joe MAyo

Board Regular
Joined
May 29, 2008
Messages
79
Sub find_Sample()
With Worksheets(1).Range("a1:z500")
Set c = .Find(sample, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Replace "s", "S"
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub
 
Upvote 0

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
try
Code:
Sub test()
Dim ws As Worksheet
For Each ws In Sheets
    ws.UsedRange.Replace What:="sample", Replacement:="Sample", _
                  MatchCase:=True 
Next
End Sub
 
Upvote 0

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,892
Hi

You can also use the Replace from the worksheet

Replace: sample
with: Sample

, check the Whole word checkbox.
 
Upvote 0

Forum statistics

Threads
1,191,500
Messages
5,986,921
Members
440,067
Latest member
Swatts1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top