Solved

Does value exist in column?

Posted on 2014-12-05
6
104 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 36

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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 36

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

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