sikander1986
Board Regular
- Joined
- Sep 6, 2008
- Messages
- 66
Hi,
I am using office 2003 & have data validations in different columns. The problem is that whenever anyone copy & paste anything in these columns the validations goes. And this is making the file size large & difficult to work.
I want to get data validations by using VBA codes & disable the normal pasting in these columns. And if anyone try to paste anything by way of normal copy & paste or paste special then they should get error message as "You are not authorize to do this function".
For Example:
In column B from B2, I have validation Yes & No, and in column D from D2 I have data validation Morning, Afternoon & Evening. The Data source for Column B is from Column G i.e. from G2 to G5 & for Column D it is from Column H i.e. from H2 to H5. Below the sample of my recording macro.
I want to get this code to work in such a way that if Column A is filled then the column B should not be blank & if its blank give the error Message as " B2 can't be blank & don't allow to save the file and if Column C is filled then the column D should not be blank & it its blank give the error message as "D2 can't be blank & don't allow to save the file.
I wan looking this to get this done in the following way of macro format.
Thank you in advance...
I am using office 2003 & have data validations in different columns. The problem is that whenever anyone copy & paste anything in these columns the validations goes. And this is making the file size large & difficult to work.
I want to get data validations by using VBA codes & disable the normal pasting in these columns. And if anyone try to paste anything by way of normal copy & paste or paste special then they should get error message as "You are not authorize to do this function".
For Example:
In column B from B2, I have validation Yes & No, and in column D from D2 I have data validation Morning, Afternoon & Evening. The Data source for Column B is from Column G i.e. from G2 to G5 & for Column D it is from Column H i.e. from H2 to H5. Below the sample of my recording macro.
Code:
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+t
'
Range("B2").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$G$2:$G$5"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
Range("D2").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=$H$2:$H$5"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
I wan looking this to get this done in the following way of macro format.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub