Solved

Does value exist in column?

Posted on 2014-12-05
6
103 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
[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
  • 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 33

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel Web Add-in Where is Visual Basic used 9 68
NEED TO LOOK FOR EXACT NUMBER 14 42
INSERT value into first row in 75 workbooks 8 33
Excel Date Question 8 41
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 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