Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Adding values to cells

The following macro lets you take a list in excel: data validation and
lets you store the values you add into the cell.

The only draw back is that you cant delete the cell information from
the top where the forumlar bar is. Whenever you do it repeats it self.

Anyone want to figure out how to change it around so you can delete the
values at the top of the formular bar?

If you look at the code you'll notice that it works when you have data
validation in columns 3 - 4-5. just add an or command for more colmns.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
If Target.Count 1 Then GoTo exitHandler

On Error Resume Next
Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation)
On Error GoTo exitHandler

If rngDV Is Nothing Then GoTo exitHandler

If Intersect(Target, rngDV) Is Nothing Then
'do nothing
Else
Application.EnableEvents = False
newVal = Target.Value
Application.Undo
oldVal = Target.Value
Target.Value = newVal
If Target.Column = 5 Or Target.Column = 3 Or Target.Column = 4 Then
If oldVal = "" Then
'do nothing
Else
If newVal = "" Then
'do nothing
Else
Target.Value = oldVal _
& ", " & newVal
End If
End If
End If
End If

exitHandler:
Application.EnableEvents = True
End Sub

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
Automatically adding values to cells... Markv Excel Discussion (Misc queries) 3 June 30th 08 03:09 PM
adding values of cells AJ Patel New Users to Excel 2 January 4th 08 10:27 PM
Adding Values to Cells Dana Excel Discussion (Misc queries) 18 December 20th 07 05:15 AM
adding values in coloured cells lois Excel Discussion (Misc queries) 2 November 5th 07 04:32 PM
Automatically adding cells with values EZ MILL Excel Discussion (Misc queries) 3 October 2nd 07 07:38 PM


All times are GMT +1. The time now is 12:29 AM.

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

About Us

"It's about Microsoft Excel"