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

Hi,

I would like to know if I can "call in" data validation using a macro.

I have a list in a certain worksheet, say Sheet "my list", and I want
to add data validation to Column A in another sheet "status". I tried
doing this manually, but then, when I run my parent macro for the
project, I have the "Clearcontents" option in that (so that when the
macro is run, it wont print out results for the previous run), and that
seems to remove the data validation property in Col A.

Can anyone help me with this? (I searched online, but most of the stuff
I found is either out of context, or too abstruse for me - I'm a
novice in VB programming, but am learning fast)

Thanks a lot,

Joe.

  #2   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default Data Validation Question

Columns("A:A").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="00", Formula2:="55"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

this add validation to column "A" for a whole number from 00 to 55. you can
edit any of the variable.
This was created using the macro recorder. Try using that to get the exact
validation you need, that way you can see proper Syntax









--
When you lose your mind, you free your life.


"Joe" wrote:

Hi,

I would like to know if I can "call in" data validation using a macro.

I have a list in a certain worksheet, say Sheet "my list", and I want
to add data validation to Column A in another sheet "status". I tried
doing this manually, but then, when I run my parent macro for the
project, I have the "Clearcontents" option in that (so that when the
macro is run, it wont print out results for the previous run), and that
seems to remove the data validation property in Col A.

Can anyone help me with this? (I searched online, but most of the stuff
I found is either out of context, or too abstruse for me - I'm a
novice in VB programming, but am learning fast)

Thanks a lot,

Joe.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Data Validation Question

Thanks a lot, Ben. I have more questions now:

1. What is a macro recorder? How can I access it?

2. My list is a bunch of strings - not numbers. What would I have to
change to the above macro to achieve that?

Thanks,

Joe.

  #4   Report Post  
Posted to microsoft.public.excel.programming
ben ben is offline
external usenet poster
 
Posts: 232
Default Data Validation Question

in excel on the main menu acess the following menu

ToolsMacrosMacro Recorder

what this does is records Actions that your perform manually in Excel and
writes them into VBA code in a module for you.

So what you need to do is

run the macro recorder
setup your data validation
stop the macro recorder

Then in VBA editor, you should now have the proper syntax for the data
validation you need.




--
When you lose your mind, you free your life.


"Joe" wrote:

Thanks a lot, Ben. I have more questions now:

1. What is a macro recorder? How can I access it?

2. My list is a bunch of strings - not numbers. What would I have to
change to the above macro to achieve that?

Thanks,

Joe.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Data Validation Question

Thanks a bunch, Ben!

Joe.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Data Validation Question

Ben,

I have a routine which adds a new row at row3 for addition of new data. The
routine includes the code listed below but has no effect. I even clicked
"Data"/"Validation"etc. and applied the settings manually. They work for the
row in question until the routine is run and then they move with the row of
data to row4. The routine specifies row3 after the new row has been added so
it should work but doesn't.

Do you have a solution for this dilemma?

Thanks,

Jim
--
Pops Jackson


"ben" wrote:

Columns("A:A").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="00", Formula2:="55"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With

this add validation to column "A" for a whole number from 00 to 55. you can
edit any of the variable.
This was created using the macro recorder. Try using that to get the exact
validation you need, that way you can see proper Syntax









--
When you lose your mind, you free your life.


"Joe" wrote:

Hi,

I would like to know if I can "call in" data validation using a macro.

I have a list in a certain worksheet, say Sheet "my list", and I want
to add data validation to Column A in another sheet "status". I tried
doing this manually, but then, when I run my parent macro for the
project, I have the "Clearcontents" option in that (so that when the
macro is run, it wont print out results for the previous run), and that
seems to remove the data validation property in Col A.

Can anyone help me with this? (I searched online, but most of the stuff
I found is either out of context, or too abstruse for me - I'm a
novice in VB programming, but am learning fast)

Thanks a lot,

Joe.


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
xls data validation question 2 t Excel Discussion (Misc queries) 2 March 12th 10 03:49 PM
Data Validation Question NFL Excel Discussion (Misc queries) 2 June 23rd 09 07:03 PM
Data Validation question ozhunter Excel Discussion (Misc queries) 3 December 16th 08 12:25 AM
Data Validation Question? mastermind Excel Worksheet Functions 2 December 22nd 06 05:26 PM
Another Data Validation question Nigel Excel Discussion (Misc queries) 3 October 14th 05 10:37 PM


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