Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 778463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:46:04+00:00 2026-05-14T19:46:04+00:00

Sub Macro1() ‘ ‘ Macro1 Macro ‘ ‘ Worksheets(Drop-down).Select For i = 1 To

  • 0
Sub Macro1()
'
' Macro1 Macro
'

'
    Worksheets("Drop-down").Select
    For i = 1 To 10
        ActiveSheet.Cells(i, 2).Select
        With Selection.Validation
            .Delete
            ' Error in this line
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
            xlBetween, Formula1:=Range(Worksheets("Misc").Cells(2, i), Worksheets("Misc").Cells(2, i).End)
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = ""
            .ShowInput = True
            .ShowError = True
        End With
    Next i
End Sub

I’m getting an error in the line below the comment, yet I don’t know how to fix it. It would be great to hear some suggestions. Thanks in advance!

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T19:46:05+00:00Added an answer on May 14, 2026 at 7:46 pm

    There are two issues; the first is you are missing a required argument for the End function, which is a named Excel constant to denote direction.

    Instead of
    Worksheets("Misc").Cells(2, i).End on that line try
    Worksheets("Misc").Cells(2, i).End(xlDown)

    You can use xlLeft, right or up as well, but I’m guessing down is what you are looking for.

    Second issue is the value for Formula1 has to be a string address (I think) and you are passing an actual range object.

    Try this for that line

    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:=Range(Worksheets("Misc").Cells(2, i), Worksheets("Misc").Cells(2, i).End(xlDown)).Address

    This worked on my machine, without errors. I of course stubbed in dummy data, so I don’t know if it is correct for your worksheet

    EDIT (in response to Stan’s comment)

    There may be a sexier way, but this is a good and simple (which is sexy too, in it’s own right); the if statement just checks the cell in the following row. If its non-empty, then it proceeds with the same solution you had before. If it’s empty, then it uses just that one cell as the validation range.

    For i = 1 To 10
        If Worksheets("Misc").Cells(3, i).Value <> "" Then
            Set validationRange = Range(Worksheets("Misc").Cells(2, i), Worksheets("Misc").Cells(2, i).End(xlDown))
        Else
            Set validationRange = Worksheets("Misc").Cells(2, i)
        End If
    
        With Worksheets("Drop-down").Cells(i, 2).Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _ 
                        Formula1:=validationRange.Address.......
    

    I combined your

    Worksheet.Selection
    Selection.DoStuff
    

    pairs, into

    Worksheet.DoStuff
    

    I think it looks a little nicer.

    Let me know if this works for ya!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 420k
  • Answers 420k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer SO i am in the process of setting up a… May 15, 2026 at 10:38 am
  • Editorial Team
    Editorial Team added an answer I've had a similar problem, fixed it by changing the… May 15, 2026 at 10:38 am
  • Editorial Team
    Editorial Team added an answer If you want to stick to pure GWT then ScrollTable… May 15, 2026 at 10:38 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.