Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Check for data in cell

I want to check to be sure the cell selected in column C has data in it
otherwise display an error message.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Check for data in cell

Hi oldjay

You can use the worksheet event shown below:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Be sure to look at a single cell
If Target.Cells.Count = 1 Then
' Check if a cell iu column C is selected
If Target.Column = 3 Then
' Check id the selected cell is empty
If IsEmpty(Target) Then
MsgBox "On empty cell"
End If
End If
End If
End Sub


HTH,

Wouter
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Check for data in cell

This code must be inserted in a sub routine so that the code doesn't continue
if a empty cell has been selected. as written it gives an error 424 'Object
required"

"Wouter HM" wrote:

Hi oldjay

You can use the worksheet event shown below:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Be sure to look at a single cell
If Target.Cells.Count = 1 Then
' Check if a cell iu column C is selected
If Target.Column = 3 Then
' Check id the selected cell is empty
If IsEmpty(Target) Then
MsgBox "On empty cell"
End If
End If
End If
End Sub


HTH,

Wouter
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Check for data in cell

Give this a shot.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 3 And Target.Cells.Count = 1Then
If Not IsEmpty(Target) And Target < "" Then
MsgBox "Has Data"
Else
MsgBox "No Data"
End If
End If
End Sub



"oldjay" wrote in message
...
This code must be inserted in a sub routine so that the code doesn't
continue
if a empty cell has been selected. as written it gives an error 424
'Object
required"

"Wouter HM" wrote:

Hi oldjay

You can use the worksheet event shown below:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Be sure to look at a single cell
If Target.Cells.Count = 1 Then
' Check if a cell iu column C is selected
If Target.Column = 3 Then
' Check id the selected cell is empty
If IsEmpty(Target) Then
MsgBox "On empty cell"
End If
End If
End If
End Sub


HTH,

Wouter
.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 337
Default Check for data in cell

I inserted Call Worksheet_SelectionChange and Call
Worksheet_SelectionChange(ByVal Target As Range) as the first line of my
Command Button to check for a proper selection but get an error message
"Argument not Optional"

"JLGWhiz" wrote:

Give this a shot.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 3 And Target.Cells.Count = 1Then
If Not IsEmpty(Target) And Target < "" Then
MsgBox "Has Data"
Else
MsgBox "No Data"
End If
End If
End Sub



"oldjay" wrote in message
...
This code must be inserted in a sub routine so that the code doesn't
continue
if a empty cell has been selected. as written it gives an error 424
'Object
required"

"Wouter HM" wrote:

Hi oldjay

You can use the worksheet event shown below:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Be sure to look at a single cell
If Target.Cells.Count = 1 Then
' Check if a cell iu column C is selected
If Target.Column = 3 Then
' Check id the selected cell is empty
If IsEmpty(Target) Then
MsgBox "On empty cell"
End If
End If
End If
End Sub


HTH,

Wouter
.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Check for data in cell

Hi,

To create a worksheet event, as my example is, open the VBE. (Use [Alt]
+[F11]).
Dubble click on the sheet where you want the event to be.
To make the project visible you might need to hit [Ctrl]+[R].
Enter the code.

Sorry, The events can no be called as yu tried.

Hoop this makes thing clear to you.

Wouter
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Check for data in cell

The code should have been put in the worksheet code module if the title line
of Private Sub Worksheet_SelectionChange() is used. Then when you select a
cell on the worksheet, if it is in column C it will trigger the procedure.
If you want to use a command button to run the procedure, you will need it
written differently and the procedure to check the cells should be put in
the public module.

For the command button:

Private Sub CommandButton1_Click()
Call ChkColC
End Sub

For the public Module1

Sub ChkColC()
If ActiveCell.Column = 3 Then
If Not IsEmpty(ActiveCell) And ActiveCell < "" Then
MsgBox "Has Data"
Else
MsgBox "No Data"
End If
End If
End Sub





"oldjay" wrote in message
...
I inserted Call Worksheet_SelectionChange and Call
Worksheet_SelectionChange(ByVal Target As Range) as the first line of my
Command Button to check for a proper selection but get an error message
"Argument not Optional"

"JLGWhiz" wrote:

Give this a shot.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 3 And Target.Cells.Count = 1Then
If Not IsEmpty(Target) And Target < "" Then
MsgBox "Has Data"
Else
MsgBox "No Data"
End If
End If
End Sub



"oldjay" wrote in message
...
This code must be inserted in a sub routine so that the code doesn't
continue
if a empty cell has been selected. as written it gives an error 424
'Object
required"

"Wouter HM" wrote:

Hi oldjay

You can use the worksheet event shown below:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Be sure to look at a single cell
If Target.Cells.Count = 1 Then
' Check if a cell iu column C is selected
If Target.Column = 3 Then
' Check id the selected cell is empty
If IsEmpty(Target) Then
MsgBox "On empty cell"
End If
End If
End If
End Sub


HTH,

Wouter
.



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I check several sheets for data in a particular cell? lee Excel Discussion (Misc queries) 0 October 25th 06 07:47 AM
Check part of cell for data Mike K. Excel Programming 1 June 21st 06 11:43 PM
how do I do a check on the data enter in the cell? Cell check Excel Programming 1 August 31st 05 11:22 AM
Check to see if cell data is within a range mwrfsu Excel Worksheet Functions 4 August 22nd 05 10:40 PM
How to check cell data Jeff Armstrong Excel Programming 1 July 28th 04 05:30 PM


All times are GMT +1. The time now is 04:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"