## AHK commands for Excel =MID() & =VALUE() Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Posts: 197
Joined: 19 Nov 2013, 08:44

### AHK commands for Excel =MID() & =VALUE()

Hello,

What AHK commands mimic the following two Excel functions?

=MID()
Syntax: MID(text, start_num, num_chars)

=VALUE()
Syntax: VALUE(text)

For example, the following formula extracts a string of 3 characters beginning with character #2:
`=MID("W369A4KM",2,3) = "369"`

And this formula converts a text string (of numbers) to a numeric value:
`=VALUE("369") = 369`

So combined,
`=VALUE(MID("W369A4KM",2,3)) = 369`

Can someone post the equivalent AHK formulas, both individually and combined?

Thanks
A ------------------------------ [A LOT OF SPACE] ------------------------------ LOT

"ALOT" is not a word — it never has been a word and it never will be a word.
"A LOT" is 2 words. Remember it as though there's [A LOT OF SPACE] between them.
FanaticGuru
Posts: 1104
Joined: 30 Sep 2013, 22:25

### Re: AHK commands for Excel =MID() & =VALUE()  Topic is solved

`X := SubStr("W369A4KM", 2, 3)MsgBox % XX := X / 3 + 5MsgBox % X`
There is not really much use for a command like "Value" in AHK. AHK does not have variable types and pretty much treats a variable like a string or a number as needed.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

Google Search, Dictionary, Thesaurus - Quickly Get Information from Specific Web Resources

[Function] Timer - Create and Manage Timers
Posts: 197
Joined: 19 Nov 2013, 08:44

### Re: AHK commands for Excel =MID() & =VALUE()

FanaticGuru wrote:There is not really much use for a command like "Value" in AHK. AHK does not have variable types and pretty much treats a variable like a string or a number as needed.

Thanks FG. That's really helpful (including the comment re variables). I need to find/create a chart showing equivalent functions because I am far more comfortable with Excel formulas than with AHK.
A ------------------------------ [A LOT OF SPACE] ------------------------------ LOT

"ALOT" is not a word — it never has been a word and it never will be a word.
"A LOT" is 2 words. Remember it as though there's [A LOT OF SPACE] between them.
FanaticGuru
Posts: 1104
Joined: 30 Sep 2013, 22:25

### Re: AHK commands for Excel =MID() & =VALUE()

WeThotUWasAToad wrote:Thanks FG. That's really helpful (including the comment re variables). I need to find/create a chart showing equivalent functions because I am far more comfortable with Excel formulas than with AHK.

It is best to use AHK functions when possible but if you really need to use an Excel function in AHK you can, assuming Excel is installed on the computer.
https://autohotkey.com/boards/viewtopic.php?p=133783#p133783

It allows stuff like this.

`Xl := ComObjCreate("Excel.Application") ; This only needs to be done once in the script (basically starts a hidden Excel running)Payment := Xl.WorksheetFunction.Pmt(5 / 1200, 6 * 12, -10000) ; Monthly Payment for \$10,000 loan at 5% for 6 years.MsgBox % PaymentXl.Quit() ; Close your hidden Excel before ending your script, could make this an OnExit routine`
Which is useful for accessing the vast number of specialized functions available in Excel.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon

Google Search, Dictionary, Thesaurus - Quickly Get Information from Specific Web Resources

[Function] Timer - Create and Manage Timers