Computer Learning Zone CLZ Access Excel Word Windows

Everyone should have their mind blown once a day.

-Neil deGrasse Tyson
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Excel Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Selection Change on data entry
Earl Brewer 
    
4 years ago
I need to know what is wrong with this macro:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Sub AddNew_Calr()
  Dim CalrDBRow As Long
  Dim CalrDBCol As Long
  If Not Intersect(Target, Range("A3:F10002")) Is Nothing Then
    CalrDBRow = Target.Row
    CalrDBCol = Target.Column
    With Sheet2
      Sheet1.Range("B2").Value = CalrDBCol
      Sheet1.Range("B3").Value = CalrDBRow
      Sheet1.Range("F6").Select
    End With
  End If
End Sub
Kevin Robertson  @Reply  
          
4 years ago
What is it supposed to do? What problems are there?

You do have an extra End Sub
Earl Brewer OP  @Reply  
    
4 years ago
it is suppose to look in the CallerDB for the name selected in F6. If found it should assign the values for CalrDBRow and CalrDBCol. Once completed it with change focus to Sheet1 F6.
Earl Brewer OP  @Reply  
    
4 years ago
I get an error that it cannot open the macro and that Target is not defined. The extra End Sub for the selctonChange sub.
Kevin Robertson  @Reply  
          
4 years ago
What is the with Sheet2 for? It doesn't appear to do anything. I thing one of the problems may be you have a sub inside another sub. Target is not defined in the sub you are calling it from.

I'm no expert in Excel VBA but try this and see if it works.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

  Dim CalrDBRow As Long
  Dim CalrDBCol As Long
  
  If Not Intersect(Target, Range("A3:F10002")) Is Nothing Then
    CalrDBRow = Target.Row
    CalrDBCol = Target.Column
    Sheet1.Range("B2").Value = CalrDBCol
    Sheet1.Range("B3").Value = CalrDBRow
    Sheet1.Range("F6").Select
  End If

End Sub

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Excel Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 7/6/2026 4:16:46 AM. PLT: 1s