-
Mar 11th, 2013, 12:49 PM
#1
Thread Starter
New Member
[RESOLVED] Prevent drop down list from moving when column deleted.
I have a spreadsheet that has a few drop down lists. The problem I will encounter is when data is pasted onto a tab, said data will fill columns A-J, columns A & B will be deleted, thus the last header will be in column H, as it should. My drop down code works, but moves when columns A and B are deleted. Is there a way to prevent this?
Code:
Sub CreateDV()
With Range("$H$2:$H$50").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="Yes,No"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
-
Mar 11th, 2013, 03:24 PM
#2
Re: Prevent drop down list from moving when column deleted.
if you put it in column j, will it move to the correct location?
can you add the drop down after the first 2 rows are removed?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Mar 11th, 2013, 03:49 PM
#3
Thread Starter
New Member
Re: Prevent drop down list from moving when column deleted.
Yes it will be in the correct position after columns are deleted, but not everyone will do it the same. I for instance delete the columns on a separate spreadsheet then paste into the working tab.
What about using find() to find a header name? Could I put that in?
-
Mar 12th, 2013, 06:39 AM
#4
Re: Prevent drop down list from moving when column deleted.
What about using find() to find a header name? Could I put that in?
of course
or last column with data
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Mar 16th, 2013, 02:15 PM
#5
Thread Starter
New Member
Re: Prevent drop down list from moving when column deleted.
I controlled this with a conditional statement, which worked out well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|