Pass Row Number Of Last Used Column Row to Variable

  • Hi all -


    This line in my code is causing an invalid qualifer error message:

    Code
    lngNew = wsNew.Range("B65536").End(xlUp).Row.Offset(1, 0)


    I am unsure why. It seems it should work


    Full code below
    Thanks
    -marc


  • Re: Pass Row Number Of Last Used Column Row to Variable


    Change to

    Code
    lngNew = wsNew.Range("B65536").End(xlUp).Row+1


    or

    Code
    Dim lngNew As Range
    Set lngNew = ws.Range("B65536").End(xlUp).Offset(1)
  • Re: Pass Row Number Of Last Used Column Row to Variable


    Thanks guys -


    Shear brilliance on my part trying to use offset on a variable dim'd as long:exclamat:
    The revised code below accomplishes exactly what I need


    Thanks much!
    -marc

  • Re: Pass Row Number Of Last Used Column Row to Variable


    marc


    Glad to see you solved the problem.:)


    But I have to ask why you have this.

    Code
    Cnt = 0


    And this.

    Code
    Cnt=0


    You don't seem to be doing any iterating and Cnt isn't declared publicly.:confused:

    Boo!:yikes:

  • Re: Pass Row Number Of Last Used Column Row to Variable


    Hi Norie -
    Wow! Long time haven't heard from you :smile:


    The code is the start for 7 other sheets in the workbook
    Once I get it working properly it's just a matter of copy/paste the code and update the sheet names for all 8 worksheets to be copied out to a new workbook.


    Thanks
    -marc

  • Re: Pass Row Number Of Last Used Column Row to Variable


    marc


    Why would you want to do that?


    Wouldn't that just be repeating the same code, perhaps with some minor changes?

    Boo!:yikes:

  • Re: Pass Row Number Of Last Used Column Row to Variable


    Hi Norie -


    Edited by marc -
    Weird. How did same message post? See above.
    The sample is to copy data from a single sheet in a workbook to a single sheet in a new workbook
    Once I got the procedure working I will copy it down and simply update the sheet name for the new snippet
    Ex. Change Grumpy to Doc.
    It is not the most efficient way to program
    But since I don't have total control of the workbook, I think it might be the best solution


    Thanks
    -marc
    =======


    Wow! Long time haven't heard from you :smile:


    The code is the start for 7 other sheets in the workbook
    Once I get it working properly it's just a matter of copy/paste the code and update the sheet names for all 8 worksheets to be copied out to a new workbook.


    Thanks
    -marc

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!