I'm using Excel 2010. I have two rows, H and I, that both have data validation enabled using a list. What I want to do is when a value is entered in one of the cells in column H have it be the default value in column I (same row) which can still be overwritten. I have named the two rows H = "Stock_UOM" and I = "Cost_UOM". This is what I have in VBA:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ColH As Range, ColI As Range
Set ColH = Range("Stock_UOM")
Set ColI = Range("Cost_UOM")
If Intersect(Target, ColH) Is Nothing Then Exit Sub
Application.EnableEvents = False
ColI = ColH
Application.EnableEvents = True
End Sub
I can get this to work if I change the named ranges to specific cells (i.e. H3 and I3) but of course it only works for that cell. I've also tried it without named ranges (H:H, I:I or H1:H65536, I1:I65536) to see if that worked but it doesn't.
Thanks.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ColH As Range, ColI As Range
Set ColH = Range("Stock_UOM")
Set ColI = Range("Cost_UOM")
If Intersect(Target, ColH) Is Nothing Then Exit Sub
Application.EnableEvents = False
ColI = ColH
Application.EnableEvents = True
End Sub
I can get this to work if I change the named ranges to specific cells (i.e. H3 and I3) but of course it only works for that cell. I've also tried it without named ranges (H:H, I:I or H1:H65536, I1:I65536) to see if that worked but it doesn't.
Thanks.