If you want to use the array approach, this might help.TXShooter wrote:FanaticGuru wrote:For something like this to work Headers[A_Index] would need to contain a column letter like "B" but the way you populated the array it will probably contain a header name like "Date".
Would my line of code above work?Columns[A_Index] := Chr(64+A_Index)
Code: Select all
DropInColumnByHeader2("Amount", 123.45)
DropInColumnByHeader2(Header, Value)
{
global xlApp
static Headers
if !xlApp ; create xlApp the first time
xlApp := ComObjActive("Excel.Application")
if !Headers ; get all the headers the first time
{
Headers := {}
for Cell in xlApp.ActiveSheet.UsedRange.Rows(1).Cells
Headers[Cell.Value] := Cell.Column
}
Header_Column := Headers[Header]
Empty_Row := xlApp.Columns(Header_Column).Find("*",,,,,2).Row + 1
xlApp.Cells(Empty_Row, Header_Column).Value := Value
}
You might be able to make something like the Columns[A_Index] := Chr(64+A_Index) work. Basically it is just saying column 1 is equal to A and column 2 is equal to B, etc. Which does not seem very useful. You really need to use the header name and the column letter if you want to use with Range.
FG