Consulting

Results 1 to 5 of 5

Thread: Paste values copied from a webpage

  1. #1

    Paste values copied from a webpage

    I want to write a macro where I go to a webpage, copy two rows of six values, return to my worksheet and paste those values into and area where I make several calculations. I then want to copy and paste the results of the calculations into a cell adjacent to an item in one of three lists on the worksheet. My macro will paste the data but then halt with an error saying the paste special failed. I appreciate any help you can offer... I'm a novice at this but can see the power.
    Tks

  2. #2
    VBAX Mentor
    Joined
    Aug 2012
    Posts
    367
    Location
    use the macro recorder - then edit your code heavily.
    test your code regularly and back-track if it breaks.
    then search on the code you don't understand and you'll find lots of commentary on how to improve the recorded code.
    Remember: it is the second mouse that gets the cheese.....

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Please post the code you have so far.

  4. #4
    VBAX Mentor
    Joined
    Aug 2012
    Posts
    367
    Location
    Sub PasteHeatmap()
        ' PasteHeatmap Macro
        On Error GoTo ErrorTrap
        With ActiveSheet
            .AutoFilterMode = False
            .Cells(1, 1).Activate
            .Cells.ClearContents
            .Cells(1, 1).Select
            .PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:=False
            .UsedRange
        End With
        Exit Sub
    ErrorTrap:
        MsgBox "Did you remember to hit 'copy'?"
    End Sub
    Activesheet is important here - I never use it willingly
    Remember: it is the second mouse that gets the cheese.....

  5. #5
    VBAX Mentor
    Joined
    Aug 2012
    Posts
    367
    Location
    activesheet.usedrange is a handy trick to reset the used range property
    Remember: it is the second mouse that gets the cheese.....

Posting Permissions

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