Advertisement

01.10.2008 at 06:26AM PST, ID: 23072475
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

VBA Code to find keywords and insert formula

Asked by Rob132332 in Visual Basic Programming, Microsoft Office Suite, Microsoft Excel Spreadsheet Software

Tags: , , ,

Using VBA in Excel 2007, the goal is to automate searching for a keyword, and then inserting a formula in column G in the row where the keyword is found (the formula is D#/F# for that same row).

My question has two parts:

1. Is the code below the best approach to satisfy this need [searching a spreadsheet of records to find a keyword that designates a row that requires action, and then using the rest of the code to insert a formula, and continuing these steps until finished]?  The code works, but I'm looking for simpler alternatives, if there are any.

2. The keyword is actually in a merged cell, and the range of A:A is not finding it.  I tested adding a row and entering the keyword with some other words, and the snippet below worked like a champ.  The second question is if there's a way to "find" keywords in merged cells.  The cells that are merged are A to C for some rows, and that format is the way it is exported from the reporting tool that the data comes from.

Thanks in advance to all experts who reply!  

Please, only VBA/macro solutions, not solutions using manual Excel steps.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
Sub Percentage()
'
' Percentage Macro
'
    With Range("A:A")   'Search First Column for "Keyword"
        Set C = .Find( _
                What:="Keyword ", _
                LookIn:=xlValues, _
                LookAt:=xlPart, _
                SearchDirection:=xlNext, _
                MatchCase:=False _
        )
        If Not C Is Nothing Then
            firstAddress = C.Address
            Do
                C.Rows.Select
                
                'Insert Calculation
                    If C.Column = 1 Then
                        ActiveCell.Offset(0, 6).FormulaR1C1 = "=RC[-3]/RC[-1]"
                    Else
                        ''
                    End If
                    
                'Next
                Set C = .FindNext(C)
                
             Loop While Not C Is Nothing And C.Address <> firstAddress
        End If
    End With
End Sub
 
Loading Advertisement...
 
[+][-]01.10.2008 at 07:51AM PST, ID: 20628032

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.10.2008 at 07:58AM PST, ID: 20628108

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Basic Programming, Microsoft Office Suite, Microsoft Excel Spreadsheet Software
Tags: Microsoft, Excel, 2007, VBA
Sign Up Now!
Solution Provided By: ahammar
Participating Experts: 1
Solution Grade: A
 
 
[+][-]01.10.2008 at 12:43PM PST, ID: 20631005

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.10.2008 at 04:54PM PST, ID: 20633176

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628