ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find Replace Visual Basic (https://www.excelbanter.com/excel-programming/424909-find-replace-visual-basic.html)

Kevin

Find Replace Visual Basic
 
I am new to VBA/macros, but have create one that prints a series of documents
that are needed each month out of the folders for each month (i.e. Nov, Dec,
Jan). I would like to add to the beginning of the code, a find and replace
function so that I don't have to go into the code prior to running the macro,
find and replace Feb with Mar, Mar with Apr, etc.

I imagine it would have something to do with having an input box where I
would enter Mar or Apr and it would run the find and replace, but I don't
know what the code would look like.

Gary''s Student

Find Replace Visual Basic
 
By using parametrs you avoid Find/Replace. Say you have code like:
Sheets("Apr").Activate
Find/Replace would result in something like:
Sheets("May").Activate

Instead:

Dim s As String
s = Application.InputBox(Prompt:="Enter month:", Type:=2)
Sheets(s).Activate

This avoids the editting.
--
Gary''s Student - gsnu200835


"Kevin" wrote:

I am new to VBA/macros, but have create one that prints a series of documents
that are needed each month out of the folders for each month (i.e. Nov, Dec,
Jan). I would like to add to the beginning of the code, a find and replace
function so that I don't have to go into the code prior to running the macro,
find and replace Feb with Mar, Mar with Apr, etc.

I imagine it would have something to do with having an input box where I
would enter Mar or Apr and it would run the find and replace, but I don't
know what the code would look like.



All times are GMT +1. The time now is 10:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com