Solved

Does value exist in column?

Posted on 2014-12-05
6
99 Views
Last Modified: 2014-12-05
In VBA I need to set a True or False value based on values in column E.
Is there a way to tell Excel to set ColumnDoesNotHaveZero = True?  If there are no zeros in that column.
Column E can have any value in it, except a "0", if there is a zero? set ColumnDoesNotHaveZero = False
Please advise and thanks.
0
Comment
Question by:RWayneH
  • 3
  • 2
6 Comments
 
LVL 35

Expert Comment

by:Kimputer
ID: 40483229
I'd say, set Worksheet_Change event, and inside, have it check only if column E was edited, enumerate every value of the column E, based on own limit, or UsedRange, and then set the ColumnDoesNotHaveZero value).
0
 

Author Comment

by:RWayneH
ID: 40483239
Worksheet is a static export from an extract.  Just need to check for it.
0
 
LVL 31

Assisted Solution

by:Rob Henson
Rob Henson earned 100 total points
ID: 40483247
Set Flag based on WorksheetFunction.COUNTIF($E:$E,0)

If Count is 0 - Flag = True; If Count >0 - Flag = False

Thanks
Rob H
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 35

Accepted Solution

by:
Kimputer earned 400 total points
ID: 40483257
Then simple VBA code will do?

Sub test()

Dim ColumnDoesNotHaveZero As Boolean

ColumnDoesNotHaveZero = True

Count = ActiveSheet.UsedRange.Rows.Count

For i = 1 To Count Step 1
    If ActiveSheet.Cells(i, 5).Value = 0 Then
        ColumnDoesNotHaveZero = False
    End If
Next

MsgBox ColumnDoesNotHaveZero

End Sub

Open in new window

0
 

Author Comment

by:RWayneH
ID: 40483258
Rob
These lines show red in the editor.
0
 

Author Closing Comment

by:RWayneH
ID: 40483284
Thank for the help.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now