+ Reply to Thread
Results 1 to 2 of 2

Name the ActiveCell

  1. #1
    Registered User
    Join Date
    01-18-2005
    Posts
    24

    Name the ActiveCell

    Ok, either i'm loosing it or i'm doing something wrong.

    Hi everyone.

    So here's my problem, i have a code where it imports a .csv file into my worksheet, it all works fine because i tell it to use cell A2 as the destination:

    With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\program files\transmitt-xls\combined.csv", _
    Destination:=Range(A2))


    But, if i do the import again, it will move everything in there currently to the right and will still use the A2 Cell, so now i'm thinking how to make it check for the last empty cell and use that as the destination.
    I have this:

    Do
    If IsEmpty(ActiveCell) = False Then
    ActiveCell.Offset(1, 0).Select
    End If
    Loop Until IsEmpty(ActiveCell) = True


    but how do i name that last empty cell and then use that in the destination? or what am i doing wrong????
    Thanks,
    Viktor.

  2. #2
    DGolds
    Guest

    RE: Name the ActiveCell

    Hi,
    This code should do the trick (assuming you're looking for the first blank
    row in Col A):

    Dim lRow As Integer
    Dim myRng As Range
    lRow = Range("A" & Rows.Count).End(xlUp).Row
    Set myRng = Range("A" & lRow + 1)
    'Your code here.
    Destination:=myRng
    HTH,
    Dave

    "Vikxcel" wrote:

    >
    > Ok, either i'm loosing it or i'm doing something wrong.
    >
    > Hi everyone.
    >
    > So here's my problem, i have a code where it imports a .csv file into
    > my worksheet, it all works fine because i tell it to use cell A2 as the
    > destination:
    >
    > -With ActiveSheet.QueryTables.Add(Connection:="TEXT;C:\program
    > files\transmitt-xls\combined.csv", _
    > Destination:=Range(A2)) -
    >
    > But, if i do the import again, it will move everything in there
    > currently to the right and will still use the A2 Cell, so now i'm
    > thinking how to make it check for the last empty cell and use that as
    > the destination.
    > I have this:
    >
    > -Do
    > If IsEmpty(ActiveCell) = False Then
    > ActiveCell.Offset(1, 0).Select
    > End If
    > Loop Until IsEmpty(ActiveCell) = True-
    >
    > but how do i name that last empty cell and then use that in the
    > destination? or what am i doing wrong????
    > Thanks,
    > Viktor.
    >
    >
    > --
    > Vikxcel
    > ------------------------------------------------------------------------
    > Vikxcel's Profile: http://www.excelforum.com/member.php...o&userid=18607
    > View this thread: http://www.excelforum.com/showthread...hreadid=477365
    >
    >


+ 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