vba find&replace

alora

New Member
Joined
Sep 20, 2016
Messages
21
Hi again,

I have one more question :)

Normally when you use excel function replace all withing sheet it will replace data just in your selection.
But if you use replace all withing workbook it will change in whole sheet(s) - regardless on your selection.

And now to the point - when you use same function in vba i unfortunately havent found any option to set up replace withing sheet/workbook.

If you use find all/replace all in sheet and run same macro it will change just in selection.
But if u used find all/replace all in workbook and run same macro it will change in workbook.

- so it seems it depends only what u have set up manually in excel before running vba macro.

- I even tried to specify in vba co find&replace just in active sheet without results... it was just continuing to change whole workbook if i was using withing workbook before running macro.

Really it cant be set up directly in vba and it depends what was user doing before running macro !?!?! Seems absurd for me.

Code just to give u better picture:

Code:
Private Sub Correct_Dates()

Application.ScreenUpdating = False


Dim Lr As Long
Dim dates As Range


Lr = Range("D5").End(xlDown).Row


For Each dates In Range("D5:E" & Lr)
If dates Like "*.*" Then
With dates
.Replace ".", "/", xlPart
.NumberFormat = "dd/mm/yy"
End With
End If
Next dates


Application.ScreenUpdating = True
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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
Back
Top