Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RS RS is offline
external usenet poster
 
Posts: 113
Default Find & Replace and Find & Insert macro help needed

This question has 2 parts to it.

QUESTION 1: FIND & REPLACE (Follow-up from a previous post).
I'm using Excel 2000 and I ran into a problem when I tried making a macro
which did a find and replace on many items on an imported spreadsheet. After
I entered 13 items, anything else I added turned a red color. Someone had
suggested that I try putting my find/replace values on a separate worksheet
in 2 columns and then use coding to do the function. Since I'm new to VB
coding I tried what was suggested but couldn't get it to work properly.

The background for this originally was posted here under the title "Find &
Replace macro limit?":
http://www.microsoft.com/office/comm...2-3e58add3b711

Basically, I added a button and clicking on it is supposed to activate the
following macro (located in Module4):

Sub Button2_Click()

For Each Cell In Worksheet("import (MACRO test) (2)").Range("rngData")
Cells.Replace What:=Cell.Value, Replacement:=Cell.Offset(0, 1).Value, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Next

End Sub

However, I get a "Compile Error: Sub or Function not defined" and the word
"Worksheet" is highlighted. When I click OK, it also highlights the 1st line
of the macro in yellow (the name of the macro). What am I doing wrong?


QUESTION 2: FIND & INSERT.
a) How can I use a similar concept to automatically find companies on a
worksheet and insert the pay rate for these companies in a separate column on
that worksheet based on either:
1) 2 different columns of criteria on the same worksheet (plus the
company name), or
2) a pay rate table located, preferably, in a different workbook (a
separate Excel file)?

Keep in mind that there are many different criteria possible, so creating a
regular formula is out of the question for this task. Also, ...

b) Would it be possible that if there is more than one rate for any company
that Excel would provide a list of choices in the rate column for those
companies (like a drop down list of choices)?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Find & Replace and Find & Insert macro help needed

I think the answer to Q1 might be that Worksheet should be Worksheets, plural.

You should probably try eating the rest of the elephant one bite at the time
by providing a proposed sheet layout for what data would be located where and
then ask how to do whatever it is you need to do with that data. Take it one
post at a time and you will probably get a quicker, better response.

"RS" wrote:

This question has 2 parts to it.

QUESTION 1: FIND & REPLACE (Follow-up from a previous post).
I'm using Excel 2000 and I ran into a problem when I tried making a macro
which did a find and replace on many items on an imported spreadsheet. After
I entered 13 items, anything else I added turned a red color. Someone had
suggested that I try putting my find/replace values on a separate worksheet
in 2 columns and then use coding to do the function. Since I'm new to VB
coding I tried what was suggested but couldn't get it to work properly.

The background for this originally was posted here under the title "Find &
Replace macro limit?":
http://www.microsoft.com/office/comm...2-3e58add3b711

Basically, I added a button and clicking on it is supposed to activate the
following macro (located in Module4):

Sub Button2_Click()

For Each Cell In Worksheet("import (MACRO test) (2)").Range("rngData")
Cells.Replace What:=Cell.Value, Replacement:=Cell.Offset(0, 1).Value, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Next

End Sub

However, I get a "Compile Error: Sub or Function not defined" and the word
"Worksheet" is highlighted. When I click OK, it also highlights the 1st line
of the macro in yellow (the name of the macro). What am I doing wrong?


QUESTION 2: FIND & INSERT.
a) How can I use a similar concept to automatically find companies on a
worksheet and insert the pay rate for these companies in a separate column on
that worksheet based on either:
1) 2 different columns of criteria on the same worksheet (plus the
company name), or
2) a pay rate table located, preferably, in a different workbook (a
separate Excel file)?

Keep in mind that there are many different criteria possible, so creating a
regular formula is out of the question for this task. Also, ...

b) Would it be possible that if there is more than one rate for any company
that Excel would provide a list of choices in the rate column for those
companies (like a drop down list of choices)?

  #3   Report Post  
Posted to microsoft.public.excel.programming
RS RS is offline
external usenet poster
 
Posts: 113
Default Find & Replace and Find & Insert macro help needed

I made Worksheet plural, but now I get a Run-time Error 1004
Application-defined or object-defined error. Clicking Debug highlights the
first line of the code in yellow. Also, how would I modify the code to limit
the search to a certain column?

Before, making a new post for the question 2, I can provide a little more
info about where the data might be located. Lets say that row 1 has headers
in it. Column J is Type, column K is Model, column L is Company and
column M is where I would want the rates to appear. The rates would be
listed on another worksheet in the same workbook or in another workbook
entirely. Sohow would the code look if it used those 3 columns (J,K, & L)
as its criteria for filling in the rates? Hope this extra info helps.


"JLGWhiz" wrote:

I think the answer to Q1 might be that Worksheet should be Worksheets, plural.

You should probably try eating the rest of the elephant one bite at the time
by providing a proposed sheet layout for what data would be located where and
then ask how to do whatever it is you need to do with that data. Take it one
post at a time and you will probably get a quicker, better response.

"RS" wrote:

This question has 2 parts to it.

QUESTION 1: FIND & REPLACE (Follow-up from a previous post).
I'm using Excel 2000 and I ran into a problem when I tried making a macro
which did a find and replace on many items on an imported spreadsheet. After
I entered 13 items, anything else I added turned a red color. Someone had
suggested that I try putting my find/replace values on a separate worksheet
in 2 columns and then use coding to do the function. Since I'm new to VB
coding I tried what was suggested but couldn't get it to work properly.

The background for this originally was posted here under the title "Find &
Replace macro limit?":
http://www.microsoft.com/office/comm...2-3e58add3b711

Basically, I added a button and clicking on it is supposed to activate the
following macro (located in Module4):

Sub Button2_Click()

For Each Cell In Worksheet("import (MACRO test) (2)").Range("rngData")
Cells.Replace What:=Cell.Value, Replacement:=Cell.Offset(0, 1).Value, _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
Next

End Sub

However, I get a "Compile Error: Sub or Function not defined" and the word
"Worksheet" is highlighted. When I click OK, it also highlights the 1st line
of the macro in yellow (the name of the macro). What am I doing wrong?


QUESTION 2: FIND & INSERT.
a) How can I use a similar concept to automatically find companies on a
worksheet and insert the pay rate for these companies in a separate column on
that worksheet based on either:
1) 2 different columns of criteria on the same worksheet (plus the
company name), or
2) a pay rate table located, preferably, in a different workbook (a
separate Excel file)?

Keep in mind that there are many different criteria possible, so creating a
regular formula is out of the question for this task. Also, ...

b) Would it be possible that if there is more than one rate for any company
that Excel would provide a list of choices in the rate column for those
companies (like a drop down list of choices)?

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
Macro needed (like find) doral Excel Discussion (Misc queries) 2 August 23rd 07 02:02 PM
Using Find and Replace to replace " in a macro snail30152 Excel Programming 1 April 13th 06 11:58 PM
FIND and REPLACE characters needed Peter C New Users to Excel 2 February 10th 06 07:09 PM
FIND and REPLACE characters needed Peter C Excel Worksheet Functions 0 February 8th 06 09:14 PM
Can I use "find / replace" to automatically "Insert Rows" in a do. Dr. Picou Excel Discussion (Misc queries) 2 September 1st 05 09:59 PM


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

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"