Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Resetting Data Validation with VBA

Hi everyone,

I'm trying to clear data validation from a range of cells in all the sheets
of a workbook.

I've found various bits of code that are doing the same sort of thing as I
need to do and Bob Phillips also helped
http://www.microsoft.com/office/comm...&lang=en&cr=US

I should have perservered at the time Bob Phillips was helping. I was taking
too long with a project so to get it finished I just recorded the whole lot,
selecting each cell and replacing contents with the ="". Of course it took
ages but seemed to work then it wouldn't. So I still haven't finished the
project and look silly because I said it was nearly there!

So I've played around and come up with this but it's not detecting the data
validation cells I get the msgbox saying No Data Validation Cells.

If anyone could help I would be more than grateful!

Option Explicit
Sub Datavalreset()
Dim rng2 As Range ' specifies range in wksh
Dim rng As Range 'specifies type of cell i.e. special cells
Dim ws As Worksheet
Dim cell As Range

For Each ws In ActiveWorkbook.Worksheets

On Error Resume Next
Set rng = Range("A1:T45")
Set rng2 = rng.Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0
If Not rng2 Is Nothing Then

For Each cell In rng2

If cell.Validation.Type = xlValidateList Then
cell.Value = ""
End If
Next
Else
MsgBox "No Data Validation Cells"
End If
Next ws
End Sub

Many thanks
--
Mifty
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Resetting Data Validation with VBA

Hi,

I've reposted because I think the routine may have stopped working when I've
added sheet protection it's protect user interface only.

--
Mifty

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Resetting Data Validation with VBA

It worked here. I had to set the data validation to be a list. You may
want to put in a debug.print statement like this inside the For each cell
section

Debug.Print cell.Address, cell.Validation.Type

xlValidateList is 3 here.
--
HTH,
Barb Reinhardt




"Mifty" wrote:

Hi everyone,

I'm trying to clear data validation from a range of cells in all the sheets
of a workbook.

I've found various bits of code that are doing the same sort of thing as I
need to do and Bob Phillips also helped
http://www.microsoft.com/office/comm...&lang=en&cr=US

I should have perservered at the time Bob Phillips was helping. I was taking
too long with a project so to get it finished I just recorded the whole lot,
selecting each cell and replacing contents with the ="". Of course it took
ages but seemed to work then it wouldn't. So I still haven't finished the
project and look silly because I said it was nearly there!

So I've played around and come up with this but it's not detecting the data
validation cells I get the msgbox saying No Data Validation Cells.

If anyone could help I would be more than grateful!

Option Explicit
Sub Datavalreset()
Dim rng2 As Range ' specifies range in wksh
Dim rng As Range 'specifies type of cell i.e. special cells
Dim ws As Worksheet
Dim cell As Range

For Each ws In ActiveWorkbook.Worksheets

On Error Resume Next
Set rng = Range("A1:T45")
Set rng2 = rng.Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0
If Not rng2 Is Nothing Then

For Each cell In rng2

If cell.Validation.Type = xlValidateList Then
cell.Value = ""
End If
Next
Else
MsgBox "No Data Validation Cells"
End If
Next ws
End Sub

Many thanks
--
Mifty

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Resetting Data Validation with VBA

Hi Barb,

How do I set a list? - sorry if this is a really basic question

Thanks for helping
--
Mifty


"Barb Reinhardt" wrote:

It worked here. I had to set the data validation to be a list. You may
want to put in a debug.print statement like this inside the For each cell
section

Debug.Print cell.Address, cell.Validation.Type

xlValidateList is 3 here.
--
HTH,
Barb Reinhardt




"Mifty" wrote:

Hi everyone,

I'm trying to clear data validation from a range of cells in all the sheets
of a workbook.

I've found various bits of code that are doing the same sort of thing as I
need to do and Bob Phillips also helped
http://www.microsoft.com/office/comm...&lang=en&cr=US

I should have perservered at the time Bob Phillips was helping. I was taking
too long with a project so to get it finished I just recorded the whole lot,
selecting each cell and replacing contents with the ="". Of course it took
ages but seemed to work then it wouldn't. So I still haven't finished the
project and look silly because I said it was nearly there!

So I've played around and come up with this but it's not detecting the data
validation cells I get the msgbox saying No Data Validation Cells.

If anyone could help I would be more than grateful!

Option Explicit
Sub Datavalreset()
Dim rng2 As Range ' specifies range in wksh
Dim rng As Range 'specifies type of cell i.e. special cells
Dim ws As Worksheet
Dim cell As Range

For Each ws In ActiveWorkbook.Worksheets

On Error Resume Next
Set rng = Range("A1:T45")
Set rng2 = rng.Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0
If Not rng2 Is Nothing Then

For Each cell In rng2

If cell.Validation.Type = xlValidateList Then
cell.Value = ""
End If
Next
Else
MsgBox "No Data Validation Cells"
End If
Next ws
End Sub

Many thanks
--
Mifty

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Resetting Data Validation with VBA

Sorry Barb,

Having another Blonde moment!

it is set as list so I'll just try the debug print statement and get back to
you
Cheers
--
Mifty


"Barb Reinhardt" wrote:

It worked here. I had to set the data validation to be a list. You may
want to put in a debug.print statement like this inside the For each cell
section

Debug.Print cell.Address, cell.Validation.Type

xlValidateList is 3 here.
--
HTH,
Barb Reinhardt




"Mifty" wrote:

Hi everyone,

I'm trying to clear data validation from a range of cells in all the sheets
of a workbook.

I've found various bits of code that are doing the same sort of thing as I
need to do and Bob Phillips also helped
http://www.microsoft.com/office/comm...&lang=en&cr=US

I should have perservered at the time Bob Phillips was helping. I was taking
too long with a project so to get it finished I just recorded the whole lot,
selecting each cell and replacing contents with the ="". Of course it took
ages but seemed to work then it wouldn't. So I still haven't finished the
project and look silly because I said it was nearly there!

So I've played around and come up with this but it's not detecting the data
validation cells I get the msgbox saying No Data Validation Cells.

If anyone could help I would be more than grateful!

Option Explicit
Sub Datavalreset()
Dim rng2 As Range ' specifies range in wksh
Dim rng As Range 'specifies type of cell i.e. special cells
Dim ws As Worksheet
Dim cell As Range

For Each ws In ActiveWorkbook.Worksheets

On Error Resume Next
Set rng = Range("A1:T45")
Set rng2 = rng.Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0
If Not rng2 Is Nothing Then

For Each cell In rng2

If cell.Validation.Type = xlValidateList Then
cell.Value = ""
End If
Next
Else
MsgBox "No Data Validation Cells"
End If
Next ws
End Sub

Many thanks
--
Mifty



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Resetting Data Validation with VBA

Hi Barb,

I'm not geting anything in the immediate window but rng2 and cell are
nothing in the watch window if that helps at all.

Could you explain what you mean by "xlValidateList is 3 here.". I'm
understanding you to mean that you were expecting the debug print statement
to return a value relating to the Xl validate list.

Thanks for your help

--
Mifty


"Mifty" wrote:

Sorry Barb,

Having another Blonde moment!

it is set as list so I'll just try the debug print statement and get back to
you
Cheers
--
Mifty


"Barb Reinhardt" wrote:

It worked here. I had to set the data validation to be a list. You may
want to put in a debug.print statement like this inside the For each cell
section

Debug.Print cell.Address, cell.Validation.Type

xlValidateList is 3 here.
--
HTH,
Barb Reinhardt




"Mifty" wrote:

Hi everyone,

I'm trying to clear data validation from a range of cells in all the sheets
of a workbook.

I've found various bits of code that are doing the same sort of thing as I
need to do and Bob Phillips also helped
http://www.microsoft.com/office/comm...&lang=en&cr=US

I should have perservered at the time Bob Phillips was helping. I was taking
too long with a project so to get it finished I just recorded the whole lot,
selecting each cell and replacing contents with the ="". Of course it took
ages but seemed to work then it wouldn't. So I still haven't finished the
project and look silly because I said it was nearly there!

So I've played around and come up with this but it's not detecting the data
validation cells I get the msgbox saying No Data Validation Cells.

If anyone could help I would be more than grateful!

Option Explicit
Sub Datavalreset()
Dim rng2 As Range ' specifies range in wksh
Dim rng As Range 'specifies type of cell i.e. special cells
Dim ws As Worksheet
Dim cell As Range

For Each ws In ActiveWorkbook.Worksheets

On Error Resume Next
Set rng = Range("A1:T45")
Set rng2 = rng.Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0
If Not rng2 Is Nothing Then

For Each cell In rng2

If cell.Validation.Type = xlValidateList Then
cell.Value = ""
End If
Next
Else
MsgBox "No Data Validation Cells"
End If
Next ws
End Sub

Many thanks
--
Mifty

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Resetting Data Validation with VBA

Hi Barb,

Could my problem be that there is no data validation on the first 3 sheets?

There are approx 30 sheets and about 6 without data val.

I've found from googling that you could specify an array of sheets you want
to use or specify which ones not to use.

What do you think?


--
Mifty


"Mifty" wrote:

Hi Barb,

I'm not geting anything in the immediate window but rng2 and cell are
nothing in the watch window if that helps at all.

Could you explain what you mean by "xlValidateList is 3 here.". I'm
understanding you to mean that you were expecting the debug print statement
to return a value relating to the Xl validate list.

Thanks for your help

--
Mifty


"Mifty" wrote:

Sorry Barb,

Having another Blonde moment!

it is set as list so I'll just try the debug print statement and get back to
you
Cheers
--
Mifty


"Barb Reinhardt" wrote:

It worked here. I had to set the data validation to be a list. You may
want to put in a debug.print statement like this inside the For each cell
section

Debug.Print cell.Address, cell.Validation.Type

xlValidateList is 3 here.
--
HTH,
Barb Reinhardt




"Mifty" wrote:

Hi everyone,

I'm trying to clear data validation from a range of cells in all the sheets
of a workbook.

I've found various bits of code that are doing the same sort of thing as I
need to do and Bob Phillips also helped
http://www.microsoft.com/office/comm...&lang=en&cr=US

I should have perservered at the time Bob Phillips was helping. I was taking
too long with a project so to get it finished I just recorded the whole lot,
selecting each cell and replacing contents with the ="". Of course it took
ages but seemed to work then it wouldn't. So I still haven't finished the
project and look silly because I said it was nearly there!

So I've played around and come up with this but it's not detecting the data
validation cells I get the msgbox saying No Data Validation Cells.

If anyone could help I would be more than grateful!

Option Explicit
Sub Datavalreset()
Dim rng2 As Range ' specifies range in wksh
Dim rng As Range 'specifies type of cell i.e. special cells
Dim ws As Worksheet
Dim cell As Range

For Each ws In ActiveWorkbook.Worksheets

On Error Resume Next
Set rng = Range("A1:T45")
Set rng2 = rng.Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo 0
If Not rng2 Is Nothing Then

For Each cell In rng2

If cell.Validation.Type = xlValidateList Then
cell.Value = ""
End If
Next
Else
MsgBox "No Data Validation Cells"
End If
Next ws
End Sub

Many thanks
--
Mifty

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
custom data validation on cells with data validation values AKrobbins Excel Worksheet Functions 2 June 21st 11 04:20 PM
Problem Resetting Data Source Ranges via VBA LarryP Charts and Charting in Excel 0 August 4th 08 08:34 PM
data validation invalid in dynamic validation list ilia Excel Discussion (Misc queries) 0 November 7th 06 12:54 PM
Data validation with validation lists and combo boxs Keith Excel Discussion (Misc queries) 1 October 12th 06 11:08 AM


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