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 6944421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:18:16+00:00 2026-05-27T13:18:16+00:00

I have a spreadsheet, it contains 18 columns. What I want to do is

  • 0

I have a spreadsheet, it contains 18 columns.
What I want to do is when doing data entry the tab will move till end of the record, i.e. 18col. Then it goes to the next row 1st col. If user wants to go at middle of the record, it won`t allow.

If it is possible to do through VBA, please help me.

Thanks

  • 1 1 Answer
  • 0 Views
  • 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-27T13:18:17+00:00Added an answer on May 27, 2026 at 1:18 pm

    If just need to keep the user from selecting outside the desired range (18 columns), you don’t even need VBA. Use sheet protection and don’t allow users to select locked cells. Here’s a quick review of how sheet protection works: http://www.dummies.com/how-to/content/how-to-protect-cell-data-in-excel-2010.html

    If you also need to enforce that cells are populated in order, you’ll need to add this VBA code. It uses an event procedure to unlock the “next” cell if the “previous” cell was populated; if it wasn’t, the current cell is moved back to the previous cell so the user can fill it in.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Dim rngPrev As Range
        Dim rngNext As Range
        Const LAST_COL As Long = 18
    
        Select Case Target.Column
            Case Is = 1
                If Target.Row > 1 Then
                    Set rngPrev = Target.Offset(-1, LAST_COL - 1)
                Else
                    Set rngPrev = Target
                End If
                Set rngNext = Target.Offset(0, 1)
            Case 2 To LAST_COL - 1
                Set rngPrev = Target.Offset(0, -1)
                Set rngNext = Target.Offset(0, 1)
            Case 18
                Set rngPrev = Target.Offset(0, -1)
                Set rngNext = Target.Offset(1, 1 - LAST_COL)
        End Select
        If Not IsEmpty(rngPrev.Value) > 0 Then
            Me.Unprotect
            rngNext.Locked = False
            ' note: this line is for testing purposes to show which cells get unlocked
            rngNext.Interior.ColorIndex = 6
            Me.Protect
        Else
            rngPrev.Activate
        End If
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, so I have an excel spreadsheet that contains data that I would like
I have a spreadsheet with 2 columns of data, column A and B, and
I have an excel spreadsheet which contains addresses. I'm reading the data from the
I have inherited an Excel spreadsheet which contains an external data query. I can
I have a spreadsheet containing 8 columns of data, A-H, each of which is
I have a spreadsheet that I am importing that contains some test data for
I have a excel spreadsheet that contains a bunch of columns. My first column
Like many, I have spreadsheet that draws data from over 40 text files as
I have a spreadsheet of data I am parsing using openpyxl's iter_rows function. However
I have a spreadsheet with multiple columns, one of which is an owner_id column.

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.