+ Reply to Thread
Results 1 to 9 of 9

How to determine the last row in a given worksheet

  1. #1
    C C
    Guest

    How to determine the last row in a given worksheet

    Hello.

    I have a macro that formats the worksheet from a text file to an excel file.
    I insert a column and create a formula on the second row of that column.
    How do I determine the last row in the worksheet so I will paste my
    formula until the last row on the new column?

    Thanks in advance.



  2. #2
    Don Guillett
    Guest

    Re: How to determine the last row in a given worksheet

    try
    lastrow=cells(rows.count,"a").end(xlup).row


    --
    Don Guillett
    SalesAid Software
    [email protected]
    "C C" <[email protected]> wrote in message
    news:[email protected]...
    > Hello.
    >
    > I have a macro that formats the worksheet from a text file to an excel

    file.
    > I insert a column and create a formula on the second row of that column.
    > How do I determine the last row in the worksheet so I will paste my
    > formula until the last row on the new column?
    >
    > Thanks in advance.
    >
    >




  3. #3
    C C
    Guest

    Re: How to determine the last row in a given worksheet

    Thanks. So after getting the "lastrow"
    how do you, say, select the range from A2 to
    the lastrow on column A?

    Thanks again.

    "Don Guillett" <[email protected]> wrote in message
    news:[email protected]...
    > try
    > lastrow=cells(rows.count,"a").end(xlup).row
    >
    >
    > --
    > Don Guillett
    > SalesAid Software
    > [email protected]
    > "C C" <[email protected]> wrote in message
    > news:[email protected]...
    >> Hello.
    >>
    >> I have a macro that formats the worksheet from a text file to an excel

    > file.
    >> I insert a column and create a formula on the second row of that column.
    >> How do I determine the last row in the worksheet so I will paste my
    >> formula until the last row on the new column?
    >>
    >> Thanks in advance.
    >>
    >>

    >
    >




  4. #4
    Don Guillett
    Guest

    Re: How to determine the last row in a given worksheet

    Post YOUR macro coding efforts for comments.

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "C C" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks. So after getting the "lastrow"
    > how do you, say, select the range from A2 to
    > the lastrow on column A?
    >
    > Thanks again.
    >
    > "Don Guillett" <[email protected]> wrote in message
    > news:[email protected]...
    > > try
    > > lastrow=cells(rows.count,"a").end(xlup).row
    > >
    > >
    > > --
    > > Don Guillett
    > > SalesAid Software
    > > [email protected]
    > > "C C" <[email protected]> wrote in message
    > > news:[email protected]...
    > >> Hello.
    > >>
    > >> I have a macro that formats the worksheet from a text file to an excel

    > > file.
    > >> I insert a column and create a formula on the second row of that

    column.
    > >> How do I determine the last row in the worksheet so I will paste my
    > >> formula until the last row on the new column?
    > >>
    > >> Thanks in advance.
    > >>
    > >>

    > >
    > >

    >
    >




  5. #5
    Dave Peterson
    Guest

    Re: How to determine the last row in a given worksheet

    Dim LastRow as long

    with activesheet
    lastrow = .cells(.rows.count,"A").end(xlup)
    .range("a2:a" & lastrow).select
    end with

    Is one way.

    Although there is very little that requires that you select a range before you
    work with it.



    C C wrote:
    >
    > Thanks. So after getting the "lastrow"
    > how do you, say, select the range from A2 to
    > the lastrow on column A?
    >
    > Thanks again.
    >
    > "Don Guillett" <[email protected]> wrote in message
    > news:[email protected]...
    > > try
    > > lastrow=cells(rows.count,"a").end(xlup).row
    > >
    > >
    > > --
    > > Don Guillett
    > > SalesAid Software
    > > [email protected]
    > > "C C" <[email protected]> wrote in message
    > > news:[email protected]...
    > >> Hello.
    > >>
    > >> I have a macro that formats the worksheet from a text file to an excel

    > > file.
    > >> I insert a column and create a formula on the second row of that column.
    > >> How do I determine the last row in the worksheet so I will paste my
    > >> formula until the last row on the new column?
    > >>
    > >> Thanks in advance.
    > >>
    > >>

    > >
    > >


    --

    Dave Peterson

  6. #6
    Norman Jones
    Guest

    Re: How to determine the last row in a given worksheet

    Hi C C,

    Try:
    '===========>>
    Sub aTester()
    Dim LRow As Long
    Const col As String = "B" '<<==== CHANGE

    LRow = Cells(Rows.Count, "A").End(xlUp).Row
    With Range(col & 2)
    .AutoFill Destination:=.Resize(LRow - 1)
    End With

    End Sub
    '<<===========

    Change B to reflect the new column.


    ---
    Regards,
    Norman



    "C C" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks. So after getting the "lastrow"
    > how do you, say, select the range from A2 to
    > the lastrow on column A?
    >
    > Thanks again.
    >
    > "Don Guillett" <[email protected]> wrote in message
    > news:[email protected]...
    >> try
    >> lastrow=cells(rows.count,"a").end(xlup).row
    >>
    >>
    >> --
    >> Don Guillett
    >> SalesAid Software
    >> [email protected]
    >> "C C" <[email protected]> wrote in message
    >> news:[email protected]...
    >>> Hello.
    >>>
    >>> I have a macro that formats the worksheet from a text file to an excel

    >> file.
    >>> I insert a column and create a formula on the second row of that column.
    >>> How do I determine the last row in the worksheet so I will paste my
    >>> formula until the last row on the new column?
    >>>
    >>> Thanks in advance.
    >>>
    >>>

    >>
    >>

    >
    >




  7. #7
    Bob Phillips
    Guest

    Re: How to determine the last row in a given worksheet

    Small omission by Dave

    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > Dim LastRow as long
    >
    > with activesheet
    > lastrow = .cells(.rows.count,"A").end(xlup)


    should be

    lastrow = .cells(.rows.count,"A").end(xlup).Row

    > .range("a2:a" & lastrow).select
    > end with




  8. #8
    Dave Peterson
    Guest

    Re: How to determine the last row in a given worksheet

    Oopsie.

    Thanks for the correction, Bob.

    Bob Phillips wrote:
    >
    > Small omission by Dave
    >
    > "Dave Peterson" <[email protected]> wrote in message
    > news:[email protected]...
    > > Dim LastRow as long
    > >
    > > with activesheet
    > > lastrow = .cells(.rows.count,"A").end(xlup)

    >
    > should be
    >
    > lastrow = .cells(.rows.count,"A").end(xlup).Row
    >
    > > .range("a2:a" & lastrow).select
    > > end with


    --

    Dave Peterson

  9. #9
    C C
    Guest

    Re: How to determine the last row in a given worksheet

    Thank you all so much. I got my macro running the way I want
    it.

    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    > Small omission by Dave
    >
    > "Dave Peterson" <[email protected]> wrote in message
    > news:[email protected]...
    >> Dim LastRow as long
    >>
    >> with activesheet
    >> lastrow = .cells(.rows.count,"A").end(xlup)

    >
    > should be
    >
    > lastrow = .cells(.rows.count,"A").end(xlup).Row
    >
    >> .range("a2:a" & lastrow).select
    >> end with

    >
    >




+ 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