Solved

Excel VBA

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

840 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