Solved

Excel VBA

Posted on 2002-03-30
2
117 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 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

8 Experts available now in Live!

Get 1:1 Help Now