Johana wrote:So you copy ONE text and this should be pasted into either one of the 3 columns? You can do it with two different ways. 1 is to use soly AHK, which copies, activates Excel and pastes in the correct field. Or you can use the much better COM. I am not good with coding but I thought I'd tell you in which direction I would check.
But something like this?
Code: Select all
1:: ; Press the number 1
Sendinput, ^C ; Copy your selection
Xl := ComObjCreate("Excel.Application") ;
Xl.Visible := True ;by default excel sheets are invisible
Xl.Workbooks.Add ;add a new workbook
Xl.Range("A1").Value := clipboard ;Send clipboard to selected cell
return
Nice start but you probably don't want to use
ComObjCreate as this will create a new Excel workbook each time.
Here is a more complete version that can handle 3 columns, putting the data in the first empty cell in each column.
Code: Select all
1::
2::
3::
Column := A_ThisHotkey + 0 ; force this to be treated as a number and not a string otherwise Excel will think you are looking for a column named the literal string 1
SendInput ^c
ClipWait,1 ; wait up to 1 second for text to appear on clipboard
if ErrorLevel ; something went wrong, abort
return
xlApp := ComObjActive("Excel.Application") ; use open Excel workbook
xlCell_EmptyBelowData := xlApp.Columns(Column).Find("*",,,,,2).Offset(1,0) ; get cell just below last cell with anything in it
if !xlCell_EmptyBelowData.Address ; no cell found with anything in it, column is blank
xlCell_EmptyBelowData := xlApp.Cells(1,Column) ; default to first cell
xlCell_EmptyBelowData.Value := Clipboard
return
FG