Single Cell - Multiple Output Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Monoxide3009
Posts: 65
Joined: 09 Apr 2018, 15:53

Single Cell - Multiple Output

31 Dec 2018, 13:43

Hello All,

I assume this will have a simple solution, but I am drawing a blank.

I have an excel sheet (that cant be edited) that has multiple entries in a single cell that I need to split up. The data points are separated by a semicolon, so I think this will have an easy solution. Example - 1702205615;1702205648;1702205653;1702205606;1702205654;1702205503 - I need to take this data and enter it into a different program.

I already have a script built that works to move all this data, but it was created with the concept that there would only ever be one data point. This is a side project that doesn't fit the normal rules of this project.

I do not believe this matters, but in case you need it, my code is below-

The cell is pulled to a variable:

Code: Select all

Asset := xlApp.Range("L"ROW).Text
The data is entered at this point:

Code: Select all

Send, cnu{enter}
Sleep, 50
Send, %Asset%{enter}
Sleep, 50
I know I can make a loop to enter multiple data points, I just dont know how to segment the data from a single variable into multiple. Please be gentle, I am self taught =p. If you offer help, be super descriptive and dont worry about sounding condescending, because I may need simple explanations.
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Single Cell - Multiple Output

31 Dec 2018, 14:01

Hi,

Just for clarification:

In Excel the data is stored in 1 cell, and it contains several values which are split by ;
You would like to paste these several values in another application one at a time.
(For example like a formular which consists of several fields.)

E.g.
Excel:
1 cell: Sven;Meier;01.01.2000;Paris

Your target application has these fields which expect such data:
Field 1: First name
Field 2: Surname
Field 3: Birthdate
Field 4: Birth town

If you just paste it as it is, the result will be:
Field 1: Sven;Meier;01.01.2000;Paris
Field 2: empty
Field 3: empty
Field 4: empty

Did I understand it correctly?
If yes, I will think about a solution.

Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Monoxide3009
Posts: 65
Joined: 09 Apr 2018, 15:53

Re: Single Cell - Multiple Output

31 Dec 2018, 15:02

Scr1pter wrote:
31 Dec 2018, 14:01
Did I understand it correctly?
What you wrote looks to be correct for what I am looking for.

I will also check out string split in the meantime.
Monoxide3009
Posts: 65
Joined: 09 Apr 2018, 15:53

Re: Single Cell - Multiple Output

31 Dec 2018, 15:05

I 'may' be able to get strsplit to work, but it looks like I have to use indexing, which I am not super familiar with. I will try to put something together and trial-and-error it. If you come up with an idea, Scr1ptor, I would still love to see it.

Sorry for the spam, I was able to get it working simply by copying what the wiki had and alter my variables.

Code: Select all

	{
	StringSplit, AssetArray, Asset, `;
	Loop, %AssetArray0%
		{
		Send, {F5}
		Sleep, 50
		Send, cnu{enter}
		Sleep, 50
			NewAsset := AssetArray%A_Index%
			Send, %NewAsset%{enter}
		Sleep, 50
		}
	}

Minor issue with it writing CNU every time, but I can figure out how to set it up in time. Thanks guys.
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Single Cell - Multiple Output

31 Dec 2018, 15:26

Okay, try this:

Code: Select all

Numpad6::
Loop, Parse, Clipboard, `; ; Split String on each ;
{
  Send %A_LoopField% ; Send value
  Sleep, d
  Send {Tab} ; Jump to next field
  Sleep, d
}
return
As Clipboard content I used the same example as in my previous post:
Sven;Meier;01.01.2000;Paris

Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: inseption86, mikeyww and 463 guests