Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Excel and VB (Excel 2000)

    Hello Everyone,

    I have created a macro and it works except for one thing.
    Basically, I copy data from a .csv file and paste it into excel. That works OK.
    However, depending on where my mouse is located when I run the macro determines
    where the data appears. If I am located on the top left cell of the paste selection, the macro runs
    perfectly and pastes the data in the correct spot, however if I run the macro from another sheet is places
    the copy cells onto that sheet.
    I know the issue is relative or absolute and I have tried both. (Clicking the button on the macro recording
    bar). It did not make a difference.

    Is there any code that will fix it?

    Thanks Kindly,

    Kerrie [img]/forums/images/smilies/smile.gif[/img]

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Excel and VB (Excel 2000)

    Have the macro tell it exactly where to paste, something like (change sheet name and range as appropriate)

    <pre>Sheets("Sheet2").Range("A1").PasteSpecial
    </pre>

    Steve

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel and VB (Excel 2000)

    Kind of hard to say without seeing the code you are using. Can you post the macro. Recorded macros usually do whatever is recorded on the active sheet and in the cell that was used when it was recorded.
    Legare Coleman

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Excel and VB (Excel 2000)

    Hi Legare,
    Sounds like the macro is coded to start pasting from the active/selected cell insted of from a specified address.
    I think Steve's on the right track with how to fix it, though seeing the code would make it easier to say exactly what needs to be changed.
    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    5 Star Lounger
    Join Date
    Oct 2002
    Location
    Wellington, Wellington, New Zealand
    Posts
    621
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Excel and VB (Excel 2000)

    I'd go further and suggest that additionally, we don't need to know <img src=/S/duck.gif border=0 alt=duck width=23 height=23>

    <font face="Georgia">Sheets("Sheet2").Range("A1").Select </font face=georgia>

    is likely to work as a cure-all in any event

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •