Google Answers Logo
View Question
 
Q: help with macro / VBA ( No Answer,   12 Comments )
Question  
Subject: help with macro / VBA
Category: Computers > Programming
Asked by: deltagirl-ga
List Price: $7.00
Posted: 03 May 2005 11:50 PDT
Expires: 06 May 2005 11:55 PDT
Question ID: 517279
I have a massive Excel spreadsheet that needs a little bit of macro
help. I need this code to act only on cells that remain visible after
data has been filtered.

So in Column G for example, I have thousands of rows of data (text)
that have been filtered to search for certain criteria, i.e.
Criteria1:="=*action*" so that all cells in which the word "action"
appears will be visible.

The column will display something like "action high" for a few hundred
rows and then will change to "action low" and then back to "action
high" or possibly "action mid". My problem is that I need to be able
to identify when the transitions occur and mark the adjacent cell in
column H,  i.e    offset(0,1).value = 1, for example, so that I can
filter on the presence of 1 in column H later on.

I'm pretty sure this is easily accomplished with If..Then within a Do..Loop?

Something like what is illustrated below...


      G		H
 
 action high
 action high
 action high
 action high
 action high
 action low	1
 action low
 action low
 action low
 action low
 action high	1
 action high
 action high
 action high
 action high
 action mid	1
 action mid
 action mid
 action mid
 action mid
 action mid
 action mid
 action high	1
 action high
 action high
 etc...
  
 any help appreciated!
Answer  
There is no answer at this time.

Comments  
Subject: Re: help with macro / VBA
From: willcodeforfood-ga on 03 May 2005 11:59 PDT
 
You can use a formula like this in column H:

=IF(G2=G1,"","1")    <-- this would go in cell H2

Now copy the H2 cell and paste it into the rest of the cells in column
H.  You'll get a #REF error in cell H1, but you can work around this
by manipulating the formula a little bit.  Is this on the right track
for you?
Subject: Re: help with macro / VBA
From: deltagirl-ga on 03 May 2005 12:07 PDT
 
WillCode...

This might work for identifying the transitions, but how do I do it
within a loop on a filtered column?
Subject: Re: help with macro / VBA
From: willcodeforfood-ga on 03 May 2005 12:34 PDT
 
I'm not terribly familiar with Excel.  Not that it's a better way
because it may well not be, but if I were in your shoes, I'd write an
Access routine to import the rows into a table, iterate through the
records to find the transitions and then insert the transition row
labels into another table.  Your filtering conditions would correspnd
to a query in Access so you'd really iterate through the query's rows
rather than the table.  You can probably find a way in Excel to do the
same thing, but it's just not my specialty.
Subject: Re: help with macro / VBA
From: mammens-ga on 03 May 2005 12:41 PDT
 
Code assumes only from cells A1-A10,change wherever necessary. 

Sub ChangedValue()
    
    Dim Bcell As Range
    Dim row As Integer
    Dim text As String
    Dim origValue As String
 
    row = 1   ' starting row
    Range("A1").Select
    origValue = ActiveCell.Value
    
    For Each Bcell In Range("A1:A10")
       myValue = Bcell.Value
       If myValue <> origValue Then
             origValue = myValue
             Range("B" & row).Select  ' select the adj row
             ActiveCell.Value = "Changed"
       End If
       row = row + 1
    Next Bcell

End Sub


Results of the code;
====================
active high	
active high	
active high	
active high	
active low	Changed
active low	
active low	
active low	
active high	Changed
active high
Subject: Re: help with macro / VBA
From: deltagirl-ga on 03 May 2005 13:04 PDT
 
oooh! This is looking promising. I didn't think of For..Next

Let me put this in and see how it works...
Subject: Re: help with macro / VBA
From: deltagirl-ga on 03 May 2005 13:33 PDT
 
Getting warm. This is working great on an unfiltered column. I tried
adding a couple of deviant entries into the column and then filtered
to display only the cells containing the string "action". When I ran
the procedure, it flagged the changed values in hidden rows as
well....

FILTERED	FLAGGED
action high	
action high	
not visible	changed
action high	changed
action high	
action low	changed
action low	
action low	
action low	
not visible	changed
action low	changed
action high	changed
action high	
action high

How to do this only on visible rows?
Subject: Re: help with macro / VBA
From: mammens-ga on 03 May 2005 13:50 PDT
 
Check for the 'Visible' property of the cell before processing and you will be
able to skip or process the cell.
Subject: Re: help with macro / VBA
From: mammens-ga on 03 May 2005 15:16 PDT
 
There you go girl!
GoodLuck..
Subject: Re: help with macro / VBA
From: mammens-ga on 03 May 2005 16:03 PDT
 
Why was my comment removed. If I'm not eligible for the payment say it
straight, and you have all the rights!

Removing the comments was so so so unprofessional and I never expected it from 
Google at all!
Subject: Re: help with macro / VBA
From: deltagirl-ga on 03 May 2005 16:30 PDT
 
mammens,

I stepped away to do some other stuff and when I returned, it seems
the moderators removed my last comment to you with the solution we had
come up with. I don't understand why this would be.

Why would you not be eligible for the payment if you provided the
answer to the problem?
Subject: Re: help with macro / VBA
From: hammer-ga on 03 May 2005 16:42 PDT
 
Commenters cannot post an official answer, which is the only way to
collect the answer fee offered. Only Google Answers Researchers can
post official answers.

I didn't see the removed comment(s), but the Editors are very likely
to remove any question, comment, or clarification that includes
personal information and/or direct contact information.

- Hammer
Subject: Re: help with macro / VBA
From: deltagirl-ga on 03 May 2005 17:07 PDT
 
I understand now. It is unfortunate that there is not a way for
mammens, who did answer my question, to receive payment for his
service...

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy