Solved

Excel VBA

Posted on 2002-03-30
2
135 Views
Last Modified: 2010-05-02
Hello again.  I was needing to find out.  How do i go about setting up a macro that will run, whenever the one of the  cells are selected on sheets "data" cell z1 or z2 or z3 or z4 or z5 or z6.  Thanks
0
Comment
Question by:sandramac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 30 total points
ID: 6908042
Hi sandramac,

this is for office questions
http://www.experts-exchange.com/jsp/qList.jsp?ta=msoffice

for your question

-bring up the VB Editor
-look in the project explorer for the sheet called Sheetx(Data)
-double click on it which will bring up the code window
-then place this code in the code window

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Rem declare vars
Dim i As Integer
i = 1
 Rem select case to look for the address of current clicked cell
 While Not i > 6
   If InStr(1, Target.Address, "$Z$", vbBinaryCompare) Then
     If Target.Address = "$Z$" & i Then
       Rem selected cell in range so show message
       MsgBox "Cell within Range selected"
       Rem run your macro here
     End If
   Else
     Rem cell is not in column so exit early
     Exit Sub
   End If
   i = i + 1
 Wend
End Sub

HTH:O)Bruintje
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6908044
instead of the messagebox you can place your macro to run in there like

If Target.Address = "$Z$" & i Then
   call macro1  
End If
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month4 days, 10 hours left to enroll

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question