+ Reply to Thread
Results 1 to 6 of 6

VBA changing Rows while keeping the columns constant

  1. #1
    Registered User
    Join Date
    12-29-2010
    Location
    Philadelphia, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    VBA changing Rows while keeping the columns constant

    Hi,


    I have the below, in which lastcolumn is a variable, but once it is set (depending on user specifications) it will remain that. What I want to to is insert the index formula into the selected cell but have the last column remain fixed. Or in other words, if you were to insert it into the worksheet directly the dollar signs would be there indicating a fixed column, while the row moves. So in this example last column is AE9, I would want the AE to stay fixed. I know a for loop (while it doesn't put dollar signs) would work going down, but not sure how to do it across. I haven't be able to find how to do it, but pretty sure it can be done. Any help is greatly appreciated.
    Please Login or Register  to view this content.

    Thanks,



    Tom

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

    Re: VBA changing Rows while keeping the columns constant

    I think get rid of the square brackets,
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-29-2010
    Location
    Philadelphia, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: VBA changing Rows while keeping the columns constant

    Thanks, Steve.

    That definitely works. It's just it won't let me do something like -LastColumn, like if I want to go back 75 columns. I tried multiplying by -1 and then inserting LastColumn, still won't work, any idea why?

    Thanks,

    Tom

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

    Re: VBA changing Rows while keeping the columns constant

    Sorry, not with you. It has to be either relative or absolute. What are you trying to do?

  5. #5
    Registered User
    Join Date
    12-29-2010
    Location
    Philadelphia, USA
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: VBA changing Rows while keeping the columns constant

    Ok sorry about that, I should have explained what I am doing better. What I am doing is referencing two columns (keeping the columns the same) while changing the rows. So my code would look something like this. If I were to just enter it into excel.
    Please Login or Register  to view this content.
    With AE and AF columns staying constant. It's simple enough it's just that AE and AF can can change it can also span more then two columns as well (but they will always be consecutive columns, so I'm trying to write logic in VBA to take that into account. I will attach my worksheet...sorry I should have done that first. I manually have typed in the code to the cells. I start in DA9 It also has some VBA so you can see what I am attempting.



    Thanks,


    Tom
    Attached Files Attached Files

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

    Re: VBA changing Rows while keeping the columns constant

    Tom - sorry, I am being slow. I still don't get what you are actually trying to achieve. Can you explain in plain English as there may be a better approach?

+ 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