How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Richard Your Own Question

Richard
Richard, Software Specialist
Category: Microsoft Office
Satisfied Customers: 16842
Experience:  Over 15 year experience resolving Microsoft Office Issues
32989067
Type Your Microsoft Office Question Here...
Richard is online now
A new question is answered every 9 seconds

hello, I would like in a specific spreasdsheet , make sure

Resolved Question:

hello, I would like in a specific spreasdsheet , make sure that a specific macro runs if a cell , say a1 in the spreadsheet=1. I have seen a similar question being asked in the forum but I cannot get it to work for me. Thanks for your help...
Submitted: 1 year ago.
Category: Microsoft Office
Expert:  Richard replied 1 year ago.
Thank you for your question, my name is Richard.

Can you please tell me which version of Excel you are using?

Thank you

Customer: replied 1 year ago.


excel 2007 is the excel version I am using

Expert:  Richard replied 1 year ago.
Than you Olie

these are the steps you need to do (also make sure you have saved your Excel sheet as a Macro Enabled Sheet .xlsm)

1) Click on the Developer tab.

2) Click on the Visual Basic icon.

3) On the left pane window, double-click the sheet where you need your code to run.

4) Now, at the top of the code window you will see (General) with a drop down, and (Declarations) with a drop down.

5) Click the drop down by (General) and select Worksheet.

6) Now in the code window you will see Private Sub Worksheet_SelectionChange(ByVal Target As Range)

7) Remove the word "Selection". You want to remove "Selection" because that means when you click on a cell in the worksheet something will happen.

8) So it will look like below when A1 has data entered.


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$1" Then

Call MyMacro

End If

End Sub

9) Meaning, when you change the value in D10, the worksheet change event will "Call" (run) your Macro

that is all you will need to do. If you have done this and still have problems, please let me know so I can assist you further.

Thank you
Customer: replied 1 year ago.


Thanks for your quick answer. I will follow your indications.


Just to be sure that I expressed my question correctly, what I need is to call and run a specific macro if and only if the value in a specific spreadsheet cell, say a1=1.


There will always be a value in A1 because the value in A1 will be a streaming price (from reuters) and I only want the macro to run if the value in A1 equals 1. Any other value for A1 should not run the macro. Tks for your help!

Expert:  Richard replied 1 year ago.
yes, in your Macro, you say

if range("A1") = 1 then

your code

end if

This will do it.

Customer: replied 1 year ago.

Hello Richie,


 


After I have created the code below, supposed to write "game over" in cell c13 if cell a1=1 but it does not seem to work. Did I forget something or did I mistype anything?


 


 


Tks for for your help


 


Olie


====


Private Sub Worksheet_Change(ByVal Target As Range)


If Target.Address = "$A$1" Then


Call mymacro


End If


End Sub


 


Sub mymacro()


If Range("A1") = 1 Then


Range("C13").Select


ActiveCell.FormulaR1C1 = "game over !"


Range("C13").Select


'your code


End If


End Sub

Expert:  Richard replied 1 year ago.
use this Olie

If Range("A1") = 1 Then

Range("C13") = "Game Over"

End if

Customer: replied 1 year ago.

Thanks Richie. Here is the code I have now but still no reaction triggering the macro to run when a value is entered in A1, it seems.


Can I send you the spreadsheet. I think the problem is simple and easy for you but I am missing something very basic, I think...sry


 


 


Private Sub Worksheet_Change(ByVal Target As Range)


If Target.Address = "$A$1" Then


Call mymacro


End If


End Sub


 


Sub mymacro()


If Range("A1") = 1 Then


Range("C13") = "Game Over"


End If


End Sub

Expert:  Richard replied 1 year ago.
yes, I can look at the spreadsheet

- Click the following link: http://www.wikisend.com
- Upload the file to that website
- Once it is uploaded, the resulting page will display a "File ID" number.
- Please, give me that "File ID Number"
Customer: replied 1 year ago.

Here it Richie. Thanks for looking into it.


 


http://wikisend.com/download/744734/oda23_richie.xltm

Expert:  Richard replied 1 year ago.
The problem is the code is in a Module.

Cut and move this code.

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$1" Then

Call mymacro

End If

End Sub

To Sheet 1 in the Visual Code window (Double Click on Sheet 1 and paste it in). It then works.

If you have any difficulties at all, please do not hesitate to let me know so I can assist you further

Thank you


Customer: replied 1 year ago.


Yahoooo!!!! it works. Tks vm for your help. I will now close the question and rate you with a big smile.


Thanks again


 


Olie

Expert:  Richard replied 1 year ago.
Thanks Olie :)

you need to run it in the actual sheet, so the event is caught, this was the problem.

If you have continued problems, or would like any additional information or assistance, please do not hesitate to let me know.

And if you can take a second to rate my service, that would be greatly appreciated.

Thank you
Richard, Software Specialist
Category: Microsoft Office
Satisfied Customers: 16842
Experience: Over 15 year experience resolving Microsoft Office Issues
Richard and 4 other Microsoft Office Specialists are ready to help you
Customer: replied 1 year ago.


Hello Richie,


 


Thanks again for your help today. I have now tried to put in the same sheet 2 such Private Sub Worksheet_Change(ByVal Target As Range)


 


Unfortunately I get the following message:


Ambiguous name detected worsheet_change


Is there anything I can do to fix this?


 


I would really appreciate your help to fix this as I would like to have several such triggers in one spreadsheet.


 


I have uploaded the file again and the link can be found below:


http://wikisend.com/download/546368/oda23_playwith.xltm


 


Tks vm.


 


 


Olie


 


 

Expert:  Richard replied 1 year ago.
Hi Olie

As we are proceeding on a new question, you need to make a new one please.

You can do so here.

http://www.justanswer.com/profile.aspx?PF=32989067&FID=7067

I can then assit you with this.

Thanks!

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer New York
< Last | Next >
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer New York
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
 
 
 

Meet The Experts:

 
 
 
  • jstinehelfer

    Information Systems Manager

    Satisfied Customers:

    36
    A+ Comptia Certified computer repair
< Last | Next >
  • http://ww2.justanswer.com/uploads/JS/jstinehelfer/2012-6-6_215146_Pictureofme1.64x64.png jstinehelfer's Avatar

    jstinehelfer

    Information Systems Manager

    Satisfied Customers:

    36
    A+ Comptia Certified computer repair
  • http://ww2.justanswer.com/uploads/JA/JasonJames122/2011-12-16_135647_jasonjamesheadshotweb.64x64.jpg JasonJames122's Avatar

    JasonJames122

    Computer Enthusiast

    Satisfied Customers:

    0
    I manage all information systems (network of Windows PC's and servers with Microsoft Office products) for a small business
  • http://ww2.justanswer.com/uploads/JE/jessmagz/2012-6-6_18129_jm.64x64.jpg Jess M.'s Avatar

    Jess M.

    Computer Support Specialist

    Satisfied Customers:

    301
    Computer Software Specialist for more than 10 years
  • http://ww2.justanswer.com/uploads/CH/chutz747/2011-11-6_14231_me.64x64.jpg The-PC-Guy's Avatar

    The-PC-Guy

    Computer Manager

    Satisfied Customers:

    274
    20 years experience providing remote computer support
  • http://ww2.justanswer.com/uploads/SP/spherrod/2012-6-6_174244_1000852.64x64.JPG Steve Herrod's Avatar

    Steve Herrod

    Computer Support Specialist

    Satisfied Customers:

    125
    Trained in Microsoft Office from 2000 through to latest version 2010.
  • http://ww2.justanswer.com/uploads/SE/Seashore2011/2011-12-6_33418_111205223015.64x64.jpg Chris L.'s Avatar

    Chris L.

    Support Specialist

    Satisfied Customers:

    124
    Certified Expert with over 10 years experience.
  • http://ww2.justanswer.com/uploads/KR/krkljatorm/2012-6-24_153417_ITMiro.64x64.jpg IT Miro's Avatar

    IT Miro

    Computer Scientist

    Satisfied Customers:

    97
    Bachelor's Degree in Information Technology, Microsoft Certified Professional
 
 
 

Related Microsoft Office Questions