Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Enter values in one range based upon values in another range...

Posted on 2008-10-22
8
Medium Priority
?
150 Views
Last Modified: 2012-05-05
Whenever "(1)" [without " "] shows up in range AQ102:AQ141 I would like VBA code to enter 0 [zero] in the corresponding cell in range AQ59:AQ98.
0
Comment
Question by:ronadair
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 22782097
Do you mean like this?
    Dim cl As Range
    For Each cl In ActiveSheet.Range("AQ102:AQ141").Cells
        If cl.Value = "(1)" Then
            cl.Offset(59 - 102, 0).Value = 0
        End If
    Next cl

Open in new window

0
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 22782124
Your specs are a little vague, but if AQ102:AQ141 are text formatted cells, the following formula will provide the zero for the corresponding cell(s).

=IF(AQ102 = "(1)",0,"")
once you have entered the formula in cell AQ59, just select the cell and drag the lower right corner down thru cell AQ98. This will copy the formula to the remaining cells.
0
 

Author Comment

by:ronadair
ID: 22782144
Graham -

I tried the code but it won't execute.  The line
If cl.Value = "(1)" Then
is highlighted in yellow.

Division produces the values in AQ102:AQ141 & a few of them come up #DIV/0!.  Could this be screwing up the code?

Ron

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 22782168
Yes. I wasn't expecting that. Try cl.Text  instead of cl.Value.
0
 

Author Comment

by:ronadair
ID: 22782191
Graham -

I tried the change... still no cigar.  ;>(

Ron
0
 

Author Closing Comment

by:ronadair
ID: 31509002
Graham -
I got rid of the #DIV/0! error with the formula
=IF(OR(Y59=0,AB8=0),0,Y59/AB8)
Your solution now works.

Thanks.
0
 

Author Comment

by:ronadair
ID: 22785013
Graham -

I fixed the #DIV/0! issue & the code worked with a minor adjustment.  Back to cl.Value and "-1" rather than "(1)".

Thanks,

Ron
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 22785443
Yes if you simply enter (1) into a cell, it is converted to -1, but if you enter '(1), you will get the text - less the apostrophe.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question