Excel

Simplify data entry to restricted columns or rows.

Ease of Use

Easy

Version tested with

2000,2003 

Submitted by:

mdmackillop

Description:

The code limits data entry to selected adjoining columns, rows or a block of cells. By choosing the appropriate MoveAfterEnter section, the next cell will be selected automatically. Toggle on/off as required. 

Discussion:

If you need to create data to two or three adjoining columns or rows, this simple macro limits the cell selection to the desired area. For a hard coded method which permits multiple data entry regions the method here can be used. http://www.vbaexpress.com/kb/getarticle.php?kb_id=346 

Code:

instructions for use

			

Sub SetScroll() If Selection.Cells.Count <> 1 Then ActiveSheet.ScrollArea = Selection.Address Else ActiveSheet.ScrollArea = "" End If End Sub

How to use:

  1. Copy above code.
  2. In Excel press Alt + F11 to enter the VBE.
  3. Press Ctrl + R to show the Project Explorer.
  4. Right-click desired file on left (in bold).
  5. Choose Insert -> Module.
  6. Paste code into the right pane.
  7. Press Alt + Q to close the VBE.
  8. Create a button or shortcut and assign it to SetScroll
  9. Save workbook before any other changes
 

Test the code:

  1. Select a range of cells, typically two or three columns
  2. Click on your button or run your shortcut
  3. Set Tools/Options/Edit/MoveAfterEnter to suit your data ebtry
  4. Select a cell in the range and start to enter your data (followed by Enter; not TAB)
  5. To clear the selection, click on the Button or run the shortcut while a single cell is selected.
 

Sample File:

ScrollArea.zip 7.11KB 

Approved by mdmackillop


This entry has been viewed 427 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express