Results 1 to 3 of 3

Use range.copy_ destination:= ... instead of range.copy range.paste is not working. Help!

Threaded View

Halil93 Use range.copy_ destination:=... 02-25-2020, 07:06 PM
romperstomper Re: Use range.copy_... 02-25-2020, 07:09 PM
Halil93 Re: Use range.copy_... 02-26-2020, 03:32 PM
  1. #1
    Registered User
    Join Date
    02-18-2020
    Location
    Madrid, Spain
    MS-Off Ver
    MS office
    Posts
    5

    Use range.copy_ destination:= ... instead of range.copy range.paste is not working. Help!

    Hi all,

    i have tried to build a makro which replaces strings( sh.Cells(j, 4) -> list of 42 to words = find what ) in other strings ( sh.Range("A2", t) -> list of words where part f strings should be replaced ), with strings ( sh.Cells(j, 5) -> list of 42 words = replace with).

    The issue i am having now is that when copying sh.Range("A2", t).Copy so a range in a column from the "A2" to the "last cell with value".
    I would like to use the

    sh.Range("A2", t).Copy
    Destination:=sh.Range("B2")
    instead of

    sh.Range("A2", t).Copy
    Range("B2").PasteSpecial
    Application.CutCopyMode = False
    But it is not working and saying " Compile Error _ expected expression "
    Does somebody now what i do wrong and why it is not working?
    Cheeers in advance .

    Here is the code

    Dim sh As Worksheet
    Dim t As Range
    Dim z As Range
    Dim j As Integer
    
    Set sh = Workbooks("pension_name_replacer.xlsm").Sheets("Input")
    Set t = sh.Range("A" & Rows.Count).End(xlUp)
    Set z = sh.Range("B" & Rows.Count).End(xlUp)
    
    sh.Activate
    
    sh.Range("A2", t).Copy
    Range("B2").PasteSpecial
    Application.CutCopyMode = False
        
        For j = 2 To 43
            
            sh.Range("B2", z).Replace sh.Cells(j, 4).Value, sh.Cells(j, 5).Value, xlPart, , False, , False, False
                 
        Next j
            
    End Sub
    Last edited by Halil93; 02-26-2020 at 03:33 PM. Reason: solved!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy range A of cells if value is in range B & paste in range B/Multiple Or
    By Jeremycad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-22-2018, 04:28 AM
  2. Copy+Paste using 'Range=Range' not working
    By toastergirl in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-20-2016, 01:25 PM
  3. [SOLVED] Help! - Copy Range (Sheet1,A10:F50), Paste Range (Sheet 2,A1:F41), Offset Range & Repeat
    By cjtimmer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-30-2015, 06:27 PM
  4. Copy and paste not working in dynamic table range!
    By dhcwong in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-04-2015, 01:33 AM
  5. [SOLVED] Copy paste in Range not working
    By vaibhav2312 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-15-2015, 07:08 AM
  6. How to change Paste Destination Range
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2014, 06:39 PM
  7. Replies: 4
    Last Post: 03-17-2013, 05:58 AM

Tags for this Thread

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