Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88809

Auto Sorting Data with VBA, Data Validated lists, and Conditional Formatting in Excel

$
0
0

I am trying to make a spreadsheet in Excel with VBA auto-sorting the data once entered or changed but I want the user to be able to select only from drop down lists and if certain cells don't match, I would like for they to change colors

I have all the data validated in list and the conditional formatting so the colors change but when I add the auto-sorting feature with VBA the data sorts but the data validated list do not change, (i.e. A1's data validated list moves to the bottom (let's say A10) but then when I want to change the "original" A1's Data list back "on" (which in now A10) it is validated with the A10's data validation and there is no way to change it to the original

Figure 1:

enter image description here

Figure 2:

enter image description here

and as you can see from Figure 1 vs Figure 2 the data validation has changed and it has thrown off my conditional formatting (the conditional formatting issue would probably be resolved the same way I would resolve the data validation issue but it thought I'd mention it anyways)

Here is my VBA Code:

Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    Range("A11").Sort Key1:=Range("A12"), _
      Order1:=xlAscending, Header:=xlYes, _
      OrderCustom:=1, MatchCase:=False, _
      Orientation:=xlTopToBottom
End Sub

I am not sure what I can do to fix this

any help would be appreciated

Thanks,


Viewing all articles
Browse latest Browse all 88809

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>