+ Reply to Thread
Results 1 to 3 of 3

moving focus to other field

  1. #1
    Registered User
    Join Date
    04-12-2011
    Location
    Gliwice, Poland
    MS-Off Ver
    Excel 2003
    Posts
    2

    moving focus to other field

    Hello,

    please explain me the line:
    Please Login or Register  to view this content.
    used for
    Please Login or Register  to view this content.
    Because I'd like to move to the new column, first line, every time when the iteration of loop is done. It doesn't work because I don't quite understand how to modify this line (Set rgD), especially I don't get Cells(Rows.Count, "B") and End(xlUp) and what for offset is here (what offset is I know).

    Thanks in advance!
    Regards!

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: moving focus to other field

    It means go to the last used cell in column B of that worksheet in that workbook, then go down one row and one column to the left and assign that cell to the variable rgD.

  3. #3
    Registered User
    Join Date
    04-12-2011
    Location
    Gliwice, Poland
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: moving focus to other field

    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:

    Please Login or Register  to view this content.

    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:
    Please Login or Register  to view this content.
    but again, there is error 400.
    Last edited by johnyjj2; 04-27-2011 at 09:55 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1