+ Reply to Thread
Results 1 to 7 of 7

Need coding help.

Hybrid View

  1. #1
    Registered User
    Join Date
    06-15-2005
    Posts
    8

    Need coding help.

    Hello,

    Jim was good enough to put me on the right track, but I'm still confused a bit (OK, a lot).

    Here is the code and the explantion within it.

    Excel 97.

    Sub DownloadFormatCopyTAB()
    '
    ' DownloadFormatCopyTAB Macro
    ' Macro recorded 17/06/05 by IBM
    '
    ' Downloads TAB data from web, formats and copies to
    ' TodaysRaces sheet at selected cell. Only cols D and E from
    ' the downloaded data should be used.
    '
    ActiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:= _
    False
    'Note the range downloaded contains data in cols D to Q.
    'only cols D and E are required.
    'The data is formatted by moving data in col F to col E.

    Range("F8", Range("F8").End(xlDown)).Cut Range("E8")

    Selection.Copy '????????

    ' How do I select only D8:Exx to copy across???

    Sheets("TodaysRaces").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    End Sub
    ......................................................

    The above works, but copies the whole lot across, instead of the required
    range D8:Exx. The downloaded data has variable items.

    Thanks
    Neddy
    Last edited by Neddy; 06-16-2005 at 09:07 PM.

  2. #2
    Damon Longworth
    Guest

    RE: Need coding help.

    Try something similar to:

    LastRow = Range("F8").End(xlDown).Row

    Range("D8:E" & LastRow).copy

    "Neddy" wrote:

    >
    > Hello,
    >
    > Jim was good enough to put me on the right track, but I'm still
    > confused a bit (OK, a lot).
    >
    > Here is the code and the explantion within it,
    >
    > Sub DownloadFormatCopyTAB()
    > '
    > ' DownloadFormatCopyTAB Macro
    > ' Macro recorded 17/06/05 by IBM
    > '
    > ' Downloads TAB data from web, formats and copies to
    > ' TodaysRaces sheet at selected cell. Only cols D and E from
    > ' the downloaded data are used.
    > '
    > ActiveSheet.PasteSpecial Format:="Text", Link:=False,
    > DisplayAsIcon:= _
    > False
    > 'Note the range downloaded contains data in cols D to Q.
    > 'only cols D and E are required.
    >
    > Range("F8", Range("F8").End(xlDown)).Cut Range("E8")
    > Selection.Copy
    >
    > ' How do I select only D8:Exx to copy across???
    >
    > Sheets("TodaysRaces").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > End Sub
    > ......................................................
    >
    > The above works, but copies the whole lot across, instead of the
    > required
    > range D8:Exx. The downloaded data has variable items.
    >
    > Thanks
    > Neddy
    >
    >
    > --
    > Neddy
    > ------------------------------------------------------------------------
    > Neddy's Profile: http://www.excelforum.com/member.php...o&userid=24345
    > View this thread: http://www.excelforum.com/showthread...hreadid=379937
    >
    >


  3. #3
    Registered User
    Join Date
    06-15-2005
    Posts
    8
    Sorry, that doesn't work. It selects D8:E to the end of the sheet. It doesn't select only cells with data.

    Thanks
    Dave

  4. #4
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Try

    Range(Range("D8:E8"), Range("D8:E8").End(xlDown)).Copy

    probably it was a typo, Damon must have meant E8 and not F8. But You may either try D8 or E8 as per your case.

    Mangesh

  5. #5
    Registered User
    Join Date
    06-15-2005
    Posts
    8
    Mangesh,

    Thanks very much, that works a treat.

    much obliged,

    Nedy

  6. #6
    Forum Contributor
    Join Date
    06-10-2004
    Location
    India
    Posts
    1,066
    Thanks for the feedback.

    Mangesh

  7. #7
    Damon Longworth
    Guest

    Re: Need coding help.

    Do you have any data in column F when this code runs? Your goal is to use a
    column that has data down to your desired row. You were using column F in
    your code. Try another column.

    If there are any blanks in your data, the "end down" process will give you
    incorrect results. It is generally better to use "end up". Something similar
    to:

    LastRow = Range("D65536").End(xlup).row

    "Neddy" wrote:

    >
    > Sorry, that doesn't work. It selects D8:E to the end of the sheet. It
    > doesn't select only cells with data.
    >
    > Thanks
    > Dave
    >
    >
    > --
    > Neddy
    > ------------------------------------------------------------------------
    > Neddy's Profile: http://www.excelforum.com/member.php...o&userid=24345
    > View this thread: http://www.excelforum.com/showthread...hreadid=379937
    >
    >

    Subject: RE: Need coding help. 6/16/2005 7:04 PM PST

    By: Damon Longworth In: microsoft.public.excel.programming


    Try something similar to:

    LastRow = Range("F8").End(xlDown).Row

    Range("D8:E" & LastRow).copy

    "Neddy" wrote:

    >
    > Hello,
    >

    Jim was good enough to put me on the right track, but I'm still
    > confused a bit (OK, a lot).
    >
    > Here is the code and the explantion within it,
    >
    > Sub DownloadFormatCopyTAB()
    > '
    > ' DownloadFormatCopyTAB Macro
    > ' Macro recorded 17/06/05 by IBM
    > '
    > ' Downloads TAB data from web, formats and copies to
    > ' TodaysRaces sheet at selected cell. Only cols D and E from
    > ' the downloaded data are used.
    > '
    > ActiveSheet.PasteSpecial Format:="Text", Link:=False,
    > DisplayAsIcon:= _
    > False
    > 'Note the range downloaded contains data in cols D to Q.
    > 'only cols D and E are required.
    >
    > Range("F8", Range("F8").End(xlDown)).Cut Range("E8")
    > Selection.Copy
    >
    > ' How do I select only D8:Exx to copy across???
    >
    > Sheets("TodaysRaces").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > End Sub
    > ......................................................
    >
    > The above works, but copies the whole lot across, instead of the
    > required
    > range D8:Exx. The downloaded data has variable items.
    >
    > Thanks
    > Neddy



+ 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