+ Reply to Thread
Results 1 to 5 of 5

Macro for copy and paste as link

Hybrid View

robrobet Macro for copy and paste as... 10-03-2013, 03:36 PM
playaller Re: Macro for copy and paste... 10-03-2013, 04:05 PM
robrobet Re: Macro for copy and paste... 10-03-2013, 04:37 PM
playaller Re: Macro for copy and paste... 10-03-2013, 05:14 PM
robrobet Re: Macro for copy and paste... 10-03-2013, 05:33 PM
  1. #1
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    165

    Macro for copy and paste as link

    Hi

    I have this macro and want to change this to when it paste it paste special as link (link to another sheet ) not value,
    Thanks
    RR

    Sub Test()
        Dim excel As excel.Application
        Dim wb As excel.Workbook
        Dim sht As excel.Worksheet
        Dim f As Object
        Set f = Application.FileDialog(3)
        f.AllowMultiSelect = False
        f.Show
        Set excel = CreateObject("excel.Application")
        Set wb = excel.Workbooks.Open(f.SelectedItems(1))
        Set sht = wb.Worksheets("Master")
            sht.Range("A1:G10").Copy
        Range("A1").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = 0
        wb.Close Save
        End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    09-01-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    324

    Re: Macro for copy and paste as link

    Hello. I removed the paste coding you had and added another method so try this.


    Sub Test()
        Dim excel As excel.Application
        Dim wb As excel.Workbook
        Dim sht As excel.Worksheet
        Dim f As Object
        Dim Link As String 'Copy the link as text first
        
        Link = Range("A1") 'Will be used to convert to hyperlink in the end
        
        Set f = Application.FileDialog(3)
        f.AllowMultiSelect = False
        f.Show
        Set excel = CreateObject("excel.Application")
        Set wb = excel.Workbooks.Open(f.SelectedItems(1))
        Set sht = wb.Worksheets("Master")
            sht.Range("A1:G10").Copy
        Range("A1").Select
        ActiveSheet.Paste
        Application.CutCopyMode = False
        'Convert the cell to a hyperlink
        ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=Link _
            , TextToDisplay:=Link
        wb.Close Save
    End Sub

  3. #3
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    165

    Re: Macro for copy and paste as link

    Thanks for your time,
    But I want link as (C:\Documents and Settings\All Users) So when ever any value change on other sheet then my this sheet get update too. I do not want hyperlink.

  4. #4
    Valued Forum Contributor
    Join Date
    09-01-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    324

    Re: Macro for copy and paste as link

    Sorry, Just use the code below:



    Sub Test2()
        Dim excel As excel.Application
        Dim wb As excel.Workbook
        Dim sht As excel.Worksheet
        Dim f As Object
        Set f = Application.FileDialog(3)
        f.AllowMultiSelect = False
        f.Show
        Set excel = CreateObject("excel.Application")
        Set wb = excel.Workbooks.Open(f.SelectedItems(1))
        Set sht = wb.Worksheets("Master")
            sht.Range("A1:G10").Copy
        Range("A1").Select
        ActiveSheet.Paste Link:=True 'Paste data linked from the original sheet
        Application.CutCopyMode = False 'Unhighlight
    
        wb.Close Save
    End Sub

  5. #5
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    165

    Re: Macro for copy and paste as link

    Thanks you it work,
    Last edited by robrobet; 10-03-2013 at 06:11 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to copy specific color cells frm multiple sheets & paste link to other similar wrkbk
    By rahulmalhotra in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2013, 11:23 AM
  2. Paste Link Not Copy Correctly
    By netchie in forum Excel General
    Replies: 0
    Last Post: 08-03-2012, 05:42 PM
  3. Simple copy/paste link query
    By md1972 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-02-2008, 10:58 AM
  4. [SOLVED] How can I copy/paste a hyperlink address without the link?
    By voluptas in forum Excel General
    Replies: 1
    Last Post: 05-29-2006, 11:20 PM
  5. Macro: Copy and Paste Boomberg Link
    By excelman in forum Excel General
    Replies: 3
    Last Post: 08-17-2005, 02:05 PM

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