PC Review


Reply
Thread Tools Rate Thread

Automate column selection

 
 
=?Utf-8?B?U25vb3B5?=
Guest
Posts: n/a
 
      27th Jan 2006
Is it possible to set up excel so that the proper column is selected for
numerical entry dependent upon a text entry in a row?
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      27th Jan 2006
Maybe.

Should a cell be selected after you type that text value in a certain column?

Or should a cell be selected when you select a cell in that row -- and the text
value in that other cell already exists???

I'm gonna guess that you type the value in column A. Then you select a cell in
the same row.

If you want to try:

Right click on the worksheet tab that should have this behavior. Select view
code and paste this into the code window that opens up.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim myOffset As Long

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub

On Error GoTo errHandler:

myOffset = 0
Select Case LCase(Target.Value)
Case Is = "a": myOffset = 1
Case Is = "b": myOffset = 3
Case Is = "x": myOffset = 18
End Select

If myOffset <> 0 Then
Application.EnableEvents = False
Target.Offset(0, myOffset).Select
End If

errHandler:
Application.EnableEvents = True

End Sub

You'll have to change the values and offsets (18 means move to the right 18
columns). And the values that get typed into column A, too.

Then back to excel to test it out.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

If you want to read more about these kinds of events:

Chip Pearson's site:
http://www.cpearson.com/excel/events.htm

David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm

Snoopy wrote:
>
> Is it possible to set up excel so that the proper column is selected for
> numerical entry dependent upon a text entry in a row?


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automate Selection kaholynn Microsoft Excel Misc 4 1st Jan 2009 04:36 PM
Automate attachment selection Padds Microsoft Outlook Form Programming 12 15th May 2008 05:03 PM
Automate cell selection mayanklal Microsoft Excel Programming 1 12th Jun 2006 04:32 PM
How to automate contact selection jpottsx1@gmail.com Microsoft Outlook VBA Programming 1 4th Nov 2005 06:50 PM
AUTOMATE DATE SELECTION, PRINT, PDF jlegoland4 Microsoft Excel Programming 0 1st Sep 2004 07:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:56 AM.