Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need to find and replace text inside a macro using vba

My employer is using an excel 2000 workbook with 30 worksheets. Employee
names are on the tabs at the bottom. The sheets are printed at the end of
the month and given to each employee.

I recorded a macro that I use to clear the data (hours worked, etc.) on all
of the worksheets when a new month starts. My employer used to clear the
contents on each sheet manually.

I also have a macro that I wrote using vba (after considerable trial and
error) that changes a name on the tab on the selected worksheet using an
input box (when a new employee is added or subtracted). If the employee
count goes down I am using a place holder (Z1 through Z9) so that it sorts
toward the end of the sheets. The macro then resorts the sheets
alphabetically.

This macro doesn't update the macro that clears the data for a new month.
When a name tab is changed I have to manually do a find and replace on the
new month macro to update the sheet name or the new month macro will freeze,
because it can't find the name after it is removed. It also needs any new
names added or it won't clear the data on the new employee(s) the following
month.

I would like to write a program in vba that ties in with the macro that
updates the tab name, to look for the old name in the monthly update macro
and replace it with the new name. That way the new month macro will run
without hanging up.

I have very little experience working with vba code and I can't find
anything that seems to work. This is my first posting. Any help will be
greatly appreciated.
--
filet2050
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Need to find and replace text inside a macro using vba

I would use a worksheet "NAME" for each tab. Excel will change the reference
for NAME when the tab is modified.

1) Go to worksheet menu Insert-Name-Define
add name JOEL for cell A1 - This will include the sheet name as well

2) Use this code to clear contenets of worksheet
cellname = Range("Joel").Worksheet.Name
Sheets(cellname).Cells.ClearContents

When the Tab name is changed the reference for JOEL will also change. The
VBA code will not have to be modified.

"filet2050" wrote:

My employer is using an excel 2000 workbook with 30 worksheets. Employee
names are on the tabs at the bottom. The sheets are printed at the end of
the month and given to each employee.

I recorded a macro that I use to clear the data (hours worked, etc.) on all
of the worksheets when a new month starts. My employer used to clear the
contents on each sheet manually.

I also have a macro that I wrote using vba (after considerable trial and
error) that changes a name on the tab on the selected worksheet using an
input box (when a new employee is added or subtracted). If the employee
count goes down I am using a place holder (Z1 through Z9) so that it sorts
toward the end of the sheets. The macro then resorts the sheets
alphabetically.

This macro doesn't update the macro that clears the data for a new month.
When a name tab is changed I have to manually do a find and replace on the
new month macro to update the sheet name or the new month macro will freeze,
because it can't find the name after it is removed. It also needs any new
names added or it won't clear the data on the new employee(s) the following
month.

I would like to write a program in vba that ties in with the macro that
updates the tab name, to look for the old name in the monthly update macro
and replace it with the new name. That way the new month macro will run
without hanging up.

I have very little experience working with vba code and I can't find
anything that seems to work. This is my first posting. Any help will be
greatly appreciated.
--
filet2050

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Need to find and replace text inside a macro using vba

Thak you Joel. It worked perfectly.
--
filet2050


"Joel" wrote:

I would use a worksheet "NAME" for each tab. Excel will change the reference
for NAME when the tab is modified.

1) Go to worksheet menu Insert-Name-Define
add name JOEL for cell A1 - This will include the sheet name as well

2) Use this code to clear contenets of worksheet
cellname = Range("Joel").Worksheet.Name
Sheets(cellname).Cells.ClearContents

When the Tab name is changed the reference for JOEL will also change. The
VBA code will not have to be modified.

"filet2050" wrote:

My employer is using an excel 2000 workbook with 30 worksheets. Employee
names are on the tabs at the bottom. The sheets are printed at the end of
the month and given to each employee.

I recorded a macro that I use to clear the data (hours worked, etc.) on all
of the worksheets when a new month starts. My employer used to clear the
contents on each sheet manually.

I also have a macro that I wrote using vba (after considerable trial and
error) that changes a name on the tab on the selected worksheet using an
input box (when a new employee is added or subtracted). If the employee
count goes down I am using a place holder (Z1 through Z9) so that it sorts
toward the end of the sheets. The macro then resorts the sheets
alphabetically.

This macro doesn't update the macro that clears the data for a new month.
When a name tab is changed I have to manually do a find and replace on the
new month macro to update the sheet name or the new month macro will freeze,
because it can't find the name after it is removed. It also needs any new
names added or it won't clear the data on the new employee(s) the following
month.

I would like to write a program in vba that ties in with the macro that
updates the tab name, to look for the old name in the monthly update macro
and replace it with the new name. That way the new month macro will run
without hanging up.

I have very little experience working with vba code and I can't find
anything that seems to work. This is my first posting. Any help will be
greatly appreciated.
--
filet2050

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
find and replace inside comments? Knox Excel Discussion (Misc queries) 3 August 31st 07 05:12 PM
Macro to find and replace text in a worksheet travis[_3_] Excel Programming 4 June 30th 07 02:55 AM
Code to find and replace words inside of a text box RJR[_2_] Excel Programming 1 February 21st 07 06:38 PM
Creating a macro to find and replace text Louise Excel Worksheet Functions 10 June 8th 05 10:29 AM
Find and Replace formatting inside of a macro mlstjohn Excel Programming 0 November 11th 04 04:16 PM


All times are GMT +1. The time now is 06:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"