Thank you very much for your answer!
I have tried to do the same but for a row, instead of a column.
I've got a file (workbook called "Payment 2011.xls" which is opened) in which I have several worksheets. First worksheet is called "01_11". In that worksheet I have got surnames in fields from B22 to X22, where X is unknown letter (or double letter, e.g. AA, AB or similar) for the column with last surname. The number of surnames varies among worksheets. I'd like to find the field with last surname. I wanted to use similar syntax but it looks like it doesn't work.
The makro is connected with the whole workbook (VBAProject (Payment 2011.xls) => Microsoft Excel Objects => ThisWorkbook) and is contained in Sub convertMacro(). The macro works (code) works without the line "lastName = ..." but if I add this line it says "Microsoft Visual Basic 400". I have tried to put 22 in brackets or without those. I've tried to add Offset(0,0) or erase it. It looks like it cannot work in any of these ways.
The code (without other fields which are initialization of others, unconnected variables and without most comments of application of the other variables) looks like this:
What can I do to correct the last line "lastName = ..."?
Thanks in advance!
Regards!
PS The opened file "Payment 2011.xls" is both input and output file. I have added the additional worksheet with empty content (later it will contain hidden auxiliary data created by macro and also not hidden output data).
PS2 I have just tried:
but again, there is error 400.
Bookmarks