Hi all, i hope someone here can give me a hand.
i need to be able to send a selection of text to the onchange function.
in coloumn C i have a range on ID's to enter and have them split up into seperate columns. now i have code that does this if you enter them individually but i need a way to do this if say i copied them all from another file.
i would also like to be able to do this with the title function.
i relise i will have to remove
If Target.Cells.Count > 1 Then
Exit Sub
End If
to accomplish this
im quite new to this style of programming so any advice on ways to shorten the code would be much appreciated as well
thanx in advance
PS im using excel 2003 if thats of any relevence
Private Sub Worksheet_Change(ByVal Target As Range)
Dim sdnArray As Variant 'Array to hold SDN once Split
Dim titleArray As Variant 'Array to Hold Title
Dim newtitle As String 'Temporary variable fro creating string from Array
Dim lArr
If Target.Cells.Count > 1 Then
Exit Sub
End If
Application.EnableEvents = False
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' Capitalise first letter of every word in Title ''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Target.Column = 6 Then ' Check if current cell is in Title
titleArray = Split(Target, " ") ' Split title at spaces
For Each lArr In titleArray ' Check each element of the array for *
If InStrRev(lArr, "*") > 0 Then ' if * is found
newtitle = newtitle & " " & Replace(lArr, "*", "") ' do not format title and remove *
Else ' and join to string in newtitle
newtitle = newtitle & " " & StrConv(lArr, vbProperCase) ' other wise format element
End If ' and join to string in newtitle
Next lArr
Target = Trim(newtitle) ' remove spaces from start and end of newtitle
End If ' and place into current cell
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' Split SDN and populate correct columns ''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If Target.Column = 3 Or Target.Column = 4 Then ' If current cell is in column 3 (object name) or 4 (numbering root)
sdnArray = Split(Target, "-") ' Split SDN at "-" and store it in an array
If UBound(sdnArray) > 2 Then
Range("B" & Target.Row).Value = sdnArray(0) ' Place Jobnumber into Job number column
Range("G" & Target.Row).Value = Target ' Copy SDN to SDN Column
Range("H" & Target.Row).Value = sdnArray(2) ' Copy Doc Type Code to Coloumn H
Range("I" & Target.Row).Value = sdnArray(3) ' Copy Locator Code
End If
'Range("E" & Target.Row).Value = UBound(sdnArray) ' Ubound returns last number in array index
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Application.EnableEvents = True
End Sub
Bookmarks