Solved

Excel VBA

Posted on 2002-03-30
2
121 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now