Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kay Kay is offline
external usenet poster
 
Posts: 129
Default delete cell value if there is data validation error

Hi
I have written macro to compare two sheets.

can any one help me to write macro -
if there is data validation error then delete the cell value (leave blank in
that cell)
so when i run this macro it should check for data validation and if there is
an error
say date field is entred incorrectly then it should delete that cell value
and leave the value blank.

Thanks a lot in advance!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default delete cell value if there is data validation error

Hi,

What am I missing? If you have data validation on your worksheet then how
can a validated cell contain incorrect data?

Mike

"kay" wrote:

Hi
I have written macro to compare two sheets.

can any one help me to write macro -
if there is data validation error then delete the cell value (leave blank in
that cell)
so when i run this macro it should check for data validation and if there is
an error
say date field is entred incorrectly then it should delete that cell value
and leave the value blank.

Thanks a lot in advance!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default delete cell value if there is data validation error

Unlike Access, which detects invalid data in existing data when data
validation is in place, Excel doesn't do that. If this person has
pre-existing data and then put data validation in place after the fact, it
will be in force for new data or when you want to change existing data that
already doesn't comply with the validation rules. I actually like that Excel
doesn't behave like Access in this instance so I can manually correct the
invalid data.
--
Please rate posts so we know when we have answered your questions. Thanks.


"Mike H" wrote:

Hi,

What am I missing? If you have data validation on your worksheet then how
can a validated cell contain incorrect data?

Mike

"kay" wrote:

Hi
I have written macro to compare two sheets.

can any one help me to write macro -
if there is data validation error then delete the cell value (leave blank in
that cell)
so when i run this macro it should check for data validation and if there is
an error
say date field is entred incorrectly then it should delete that cell value
and leave the value blank.

Thanks a lot in advance!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default delete cell value if there is data validation error

Give this a try...

Sub DeleteInvalidData()
Dim C As Range
For Each C In Selection
If C.Validation.Value = False Then C.Clear
Next
End Sub

where you would obviously select the cells you want to test before running
it.

--
Rick (MVP - Excel)


"Orion Cochrane" wrote in message
...
Unlike Access, which detects invalid data in existing data when data
validation is in place, Excel doesn't do that. If this person has
pre-existing data and then put data validation in place after the fact, it
will be in force for new data or when you want to change existing data
that
already doesn't comply with the validation rules. I actually like that
Excel
doesn't behave like Access in this instance so I can manually correct the
invalid data.
--
Please rate posts so we know when we have answered your questions. Thanks.


"Mike H" wrote:

Hi,

What am I missing? If you have data validation on your worksheet then how
can a validated cell contain incorrect data?

Mike

"kay" wrote:

Hi
I have written macro to compare two sheets.

can any one help me to write macro -
if there is data validation error then delete the cell value (leave
blank in
that cell)
so when i run this macro it should check for data validation and if
there is
an error
say date field is entred incorrectly then it should delete that cell
value
and leave the value blank.

Thanks a lot in advance!


  #5   Report Post  
Posted to microsoft.public.excel.programming
Kay Kay is offline
external usenet poster
 
Posts: 129
Default delete cell value if there is data validation error

Thanks for your quick response.

Actually what i am doing , i am comparing two sheets - sheet1 with sheet2
my input is in sheet1 and i update sheet2 by comparing sheet1.

i dont know some how it copies the value of sheet1 into sheet 2 even if
there is data validation.
For eg Phone number in sheet 2 is number format. ( Sheet 1 does not have
data validatation and dont want to put validation for that column for some
reason)
So incase if some one enters text in sheet 1 , it will copy that value and
add/update to sheet2 (when i run that compare macro).
so i want to check if there is invlalid data in the sheet 2 then delete that
data and leave cell value as blank.

Hope i explained well.
Thanks



"Mike H" wrote:

Hi,

What am I missing? If you have data validation on your worksheet then how
can a validated cell contain incorrect data?

Mike

"kay" wrote:

Hi
I have written macro to compare two sheets.

can any one help me to write macro -
if there is data validation error then delete the cell value (leave blank in
that cell)
so when i run this macro it should check for data validation and if there is
an error
say date field is entred incorrectly then it should delete that cell value
and leave the value blank.

Thanks a lot in advance!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default delete cell value if there is data validation error

If you are doing a straight copy-&-paste between Sheet1 (no validation) and
Sheet2 (with validation), you are copying Sheet1's properties as well as
contents. Therefore, Sheet2 will not have data validation if Sheet1 doesn't.
Try pasting as values instead so you can keep Sheet2's data validation.
<This is hopefully the part where someone who knows how to Paste Special in
VBA reads this and replies with how to Paste Values, as I do not know how to
do that
--
Please rate posts so we know when we have answered your questions. Thanks.


"kay" wrote:

Thanks for your quick response.

Actually what i am doing , i am comparing two sheets - sheet1 with sheet2
my input is in sheet1 and i update sheet2 by comparing sheet1.

i dont know some how it copies the value of sheet1 into sheet 2 even if
there is data validation.
For eg Phone number in sheet 2 is number format. ( Sheet 1 does not have
data validatation and dont want to put validation for that column for some
reason)
So incase if some one enters text in sheet 1 , it will copy that value and
add/update to sheet2 (when i run that compare macro).
so i want to check if there is invlalid data in the sheet 2 then delete that
data and leave cell value as blank.

Hope i explained well.
Thanks



"Mike H" wrote:

Hi,

What am I missing? If you have data validation on your worksheet then how
can a validated cell contain incorrect data?

Mike

"kay" wrote:

Hi
I have written macro to compare two sheets.

can any one help me to write macro -
if there is data validation error then delete the cell value (leave blank in
that cell)
so when i run this macro it should check for data validation and if there is
an error
say date field is entred incorrectly then it should delete that cell value
and leave the value blank.

Thanks a lot in advance!

  #7   Report Post  
Posted to microsoft.public.excel.programming
Kay Kay is offline
external usenet poster
 
Posts: 129
Default delete cell value if there is data validation error

Thanks
i am using this formula to update value from sheet 1
where it reades cell value from sheet 1 and compare with sheet2
if there is any change then update the value.
readcells3 < readcellsc3 Then
ActiveCell.Value = readcells3
so that works fine.

data validation error does not happen frequently but
sometimes it happens and thats why i need to run some kind of macro which
just delete the cell value. so to run another macro it wont give error .

appreciate your help.

"Orion Cochrane" wrote:

If you are doing a straight copy-&-paste between Sheet1 (no validation) and
Sheet2 (with validation), you are copying Sheet1's properties as well as
contents. Therefore, Sheet2 will not have data validation if Sheet1 doesn't.
Try pasting as values instead so you can keep Sheet2's data validation.
<This is hopefully the part where someone who knows how to Paste Special in
VBA reads this and replies with how to Paste Values, as I do not know how to
do that
--
Please rate posts so we know when we have answered your questions. Thanks.


"kay" wrote:

Thanks for your quick response.

Actually what i am doing , i am comparing two sheets - sheet1 with sheet2
my input is in sheet1 and i update sheet2 by comparing sheet1.

i dont know some how it copies the value of sheet1 into sheet 2 even if
there is data validation.
For eg Phone number in sheet 2 is number format. ( Sheet 1 does not have
data validatation and dont want to put validation for that column for some
reason)
So incase if some one enters text in sheet 1 , it will copy that value and
add/update to sheet2 (when i run that compare macro).
so i want to check if there is invlalid data in the sheet 2 then delete that
data and leave cell value as blank.

Hope i explained well.
Thanks



"Mike H" wrote:

Hi,

What am I missing? If you have data validation on your worksheet then how
can a validated cell contain incorrect data?

Mike

"kay" wrote:

Hi
I have written macro to compare two sheets.

can any one help me to write macro -
if there is data validation error then delete the cell value (leave blank in
that cell)
so when i run this macro it should check for data validation and if there is
an error
say date field is entred incorrectly then it should delete that cell value
and leave the value blank.

Thanks a lot in advance!

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default delete cell value if there is data validation error

I'm just wondering if you were able to see my previous response in this
thread? I ask because I posted a macro which does what I think you appear to
still be asking for.

--
Rick (MVP - Excel)


"kay" wrote in message
...
Thanks
i am using this formula to update value from sheet 1
where it reades cell value from sheet 1 and compare with sheet2
if there is any change then update the value.
readcells3 < readcellsc3 Then
ActiveCell.Value = readcells3
so that works fine.

data validation error does not happen frequently but
sometimes it happens and thats why i need to run some kind of macro which
just delete the cell value. so to run another macro it wont give error .

appreciate your help.

"Orion Cochrane" wrote:

If you are doing a straight copy-&-paste between Sheet1 (no validation)
and
Sheet2 (with validation), you are copying Sheet1's properties as well as
contents. Therefore, Sheet2 will not have data validation if Sheet1
doesn't.
Try pasting as values instead so you can keep Sheet2's data validation.
<This is hopefully the part where someone who knows how to Paste Special
in
VBA reads this and replies with how to Paste Values, as I do not know how
to
do that
--
Please rate posts so we know when we have answered your questions.
Thanks.


"kay" wrote:

Thanks for your quick response.

Actually what i am doing , i am comparing two sheets - sheet1 with
sheet2
my input is in sheet1 and i update sheet2 by comparing sheet1.

i dont know some how it copies the value of sheet1 into sheet 2 even if
there is data validation.
For eg Phone number in sheet 2 is number format. ( Sheet 1 does not
have
data validatation and dont want to put validation for that column for
some
reason)
So incase if some one enters text in sheet 1 , it will copy that value
and
add/update to sheet2 (when i run that compare macro).
so i want to check if there is invlalid data in the sheet 2 then delete
that
data and leave cell value as blank.

Hope i explained well.
Thanks



"Mike H" wrote:

Hi,

What am I missing? If you have data validation on your worksheet then
how
can a validated cell contain incorrect data?

Mike

"kay" wrote:

Hi
I have written macro to compare two sheets.

can any one help me to write macro -
if there is data validation error then delete the cell value (leave
blank in
that cell)
so when i run this macro it should check for data validation and if
there is
an error
say date field is entred incorrectly then it should delete that
cell value
and leave the value blank.

Thanks a lot in advance!


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
Data Validation - Prevent delete apache007 Excel Discussion (Misc queries) 2 March 2nd 10 12:47 AM
1004 Cell Protected Error for data validation lists when locked and protected [email protected] Excel Programming 2 November 7th 06 10:07 AM
Invalid Validation if cell "Delete"d RWN Excel Worksheet Functions 4 March 19th 05 07:29 PM
question data validation and delete/clear behavior Jeff Higgins Excel Programming 0 January 23rd 05 08:09 PM


All times are GMT +1. The time now is 05:50 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"