DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: My first excel macro  (Read 10,480 times)

kalos

  • Member
  • Joined in 2006
  • **
  • Posts: 1,824
My first excel macro
« on: October 09, 2018, 02:48 PM »
Hello!

I want to write a macro in Excel that will use the 'Goal Seek' analysis.

The code is something like that:

Range("Q27").GoalSeek Goal:=0, ChangingCell:=Range("B10")

As for input cell (ChangingCell), when the macro button is pressed, I want to consider the active cell. How can I do that?
As for the goal seek cell, I want to a formula to calculate it based on other cells values.

Any hint?

Thanks!

KodeZwerg

  • Honorary Member
  • Joined in 2018
  • **
  • Posts: 718
    • Participated in NANY Challenge Four Times
    • Coding Snacks
Re: My first excel macro
« Reply #1 on: October 09, 2018, 03:26 PM »
i do not want to scare some one off, i am sorry,
Spoiler (click to show/hide)
You really should consider to put your nose in a book.
If this is too expensive for you to learn, how about a visit to the public library?
Those are my Hints.
« Last Edit: October 09, 2018, 07:10 PM by KodeZwerg »

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 11,205
    • Participated in NANY Challenge Fourteen Times
    • Coding Snacks
    • Writer
    • Hardware Hacker
Re: My first excel macro
« Reply #2 on: October 09, 2018, 06:57 PM »
You really should consider to put your nose in a book.
If this is too expensive for you to learn, how about a visit to the public library?

Those are my Hints.

It's better not to answer, and let silence speak for itself, rather than to post snark, in my opinion.  DC remains a very open and inviting site, and some do seem not to help themselves.  But our responses to them can scare off others that we really could help.

kalos

  • Member
  • Joined in 2006
  • **
  • Posts: 1,824
Re: My first excel macro
« Reply #3 on: October 09, 2018, 09:22 PM »
What I am asking is not a google search and I don't have the time now to read a whole tutorial

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: My first excel macro
« Reply #4 on: October 09, 2018, 09:37 PM »
Quote
It's better not to answer, and let silence speak for itself, rather than to post snark, in my opinion.  DC remains a very open and inviting site, and some do seem not to help themselves.  But our responses to them can scare off others that we really could help.

What Wraith said.  We must all remember to be kind and polite.  If you feel like someone should search for answer themselves, wither let your silence speak or give them some kind encouragement to go search for themselves... We try to avoid snark and sarcasm here, even though the current era we live in thrives on it.. it's just not the DC way :)

KodeZwerg

  • Honorary Member
  • Joined in 2018
  • **
  • Posts: 718
    • Participated in NANY Challenge Four Times
    • Coding Snacks
Re: My first excel macro
« Reply #5 on: October 09, 2018, 09:54 PM »
That was no sarcasm, that was meant kinda real, if i do not know something and have many questions to that subject, i go to library and rent a book or quick way, buy ebook.
If such possibilty is not available at your place, i am sorry.
But okay, i've taken your advice and keep my mouth better shut.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: My first excel macro
« Reply #6 on: October 09, 2018, 09:59 PM »
Don't keep your mouth shut, just infuse some kindness when you give advice, even if you might feel frustrated -- it makes new readers feel more welcome and comfortable.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: My first excel macro
« Reply #7 on: October 09, 2018, 10:31 PM »
The ironic thing is, this question from Kalos is one of his most reasonable and specific requests for advice, and a question that might not yield a quick easy solution with a google search.. Sounds like something someone might be able to give some advice about, or at least point him in the right direction..

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,840
    • Coding Snacks
Re: My first excel macro
« Reply #8 on: October 09, 2018, 10:45 PM »
for changing cell use 'ActiveCell'
Alcohol is photoshop, bottled
Askhole - someone who ask for advice, then ignores it
"Look wise, say nothing, and grunt. Speech was given to conceal thought" - Sir William Osler

IainB

  • @Slartibartfarst
  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,544
Re: My first excel macro
« Reply #9 on: October 09, 2018, 10:54 PM »
At the risk of repeating myself:
@Stephen66515: "Ethics" is usually more about maintaining moral principles in behaviour and business. It would seem to be just plain rudeness/bad manners to tell people to "google it" or "RTFM", and my principles prevent me from being rude to others.
After years of lecturing, consulting and generally trying to maintain a politely helpful and positive approach to people's questions (including being a volunteer on aardvark), I eventually decided on three (sorry, four) basic rules:
Rule 1: that there is no limit to our ignorance (including mine), and I should accept that;
Rule 2: to limit the contribution of my cognitive surplus to such people and their infinite ignorance/questions, by encouraging them to take more responsibility for seeking out/discovering their own answers.
Rule 3: that people generally seem to have little respect for and to have a limited capacity to internalise answers/knowledge which have come too easily to them, so generally avoid giving them any answers.
Rule 4: in any event, avoid "telling them the answer" or pushing my opinion forwards without substantiation in theory, experience and good practice (this takes work to communicate).

When I have strayed from these rules, I have usually regretted it (I think it has happened once in the DC forum).

Therefore, rather than tell people to "google it" or "RTFM", IF I decide to assist them at all, then - and even if I think that I know the answer already - I nowadays usually google it, or check Wikipedia (say) or RTFM for them, and then send them the results or source links, with the suggestion that  they could probably get even more useful information if they hunted around a bit more themselves or played about with the google search string. This is just helping people to help themselves.

...RTFM is never an acceptable answer to any question. Because it is not an answer at all. It's just a thinly disguised way of telling someone to get lost. ...
...Consider: It only takes a few seconds to type RTFM and hit the enter key. But it takes exactly zero work to ignore something completely and go elsewhere. Ideally where you do have something real to contribute.


("Take a man up in a helicopter for a day and he will be able fly for a day. Push him out of the helicopter whilst it is flying and he will fly for the rest of his life."
- ancient Chinese proverb.)
« Last Edit: October 09, 2018, 11:14 PM by IainB »

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • Cody Award
    • Official Forum Clown
    • rotten turkey sandwich - Rotten Turkey Sandwich
Re: My first excel macro
« Reply #10 on: October 10, 2018, 03:02 AM »
I want to write a macro in Excel that will use the 'Goal Seek' analysis.
Wow! For a giddy moment the topic title made me think you'd actually done something yourself... silly me.

Have you ever looked at Excel's built-in help?
Chris

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 9,827
    • Participated in NANY Challenge Eight Times
    • Cody Award
Re: My first excel macro
« Reply #11 on: October 10, 2018, 04:26 AM »
The ironic thing is, this question from Kalos is one of his most reasonable and specific requests for advice, and a question that might not yield a quick easy solution with a google search.. Sounds like something someone might be able to give some advice about, or at least point him in the right direction..

The Boy Who Cried Wolf comes to mind.

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Re: My first excel macro
« Reply #12 on: October 11, 2018, 02:29 AM »
... and a question that might not yield a quick easy solution with a google search..

And yet if a complete Excel agnostic, (ie. me), can find information within minutes using words from the OP, what should someone who uses Excel be able to do?

SearX

SearX

The Boy Who Cried Wolf comes to mind.

I don't think that's the problem, I don't mind how many times he asks for something because there are times when I learn something, (eg. the recent RegEx thread).

The main problem is the low quality questions and the almost complete lack of feedback/response to any suggestions/questions which are posed in order to get a clearer picture of what he's trying to achieve, ie. he's not interested enough to help us help him.

Have you ever looked at Excel's built-in help?

Sounds suspiciously like RTM  :P
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903
« Last Edit: October 11, 2018, 08:11 AM by 4wd »

Original address: https://www.donationcoder.com/forum/index.php?topic=46504.0