VBA Copy Merged Cells

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
840
Hello my code below, V6 is a single cell and copys perfectly - with D6, it is merged to D6:E7, how do I make this copy too? I have tried D6 but I am yet to have any joy, many thanks.

Code:
Private Sub Data_to_Database()


 Application.ScreenUpdating = False


    Dim NextRow As Range
    
    Sheets("Entry - Accidents").Range("V6", "D6").Copy
        
    Sheets("Data - Accidents").Select
    Set NextRow = ActiveSheet.Cells(Cells.Rows.Count, 1).End(xlUp).Offset(1, 0)
    NextRow.Select
    Selection.PasteSpecial (xlValues), Transpose:=True

End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Instead of using copy paste you can try to just set the value from the other cell's value... maybe that will work... copying merged cells and pasting on a different sized area might be an issue. When you do it manually, Excel I believe shows an error message. Try just using values and setting them.

Code:
Range("D6").Value = Range("V6").Value
 
Upvote 0
Hello my code below, V6 is a single cell and copys perfectly - with D6, it is merged to D6:E7, how do I make this copy too? I have tried D6 but I am yet to have any joy, many thanks.

Code:
Private Sub Data_to_Database()


 Application.ScreenUpdating = False


    Dim NextRow As Range
    
    Sheets("Entry - Accidents").Range("V6", "D6").Copy
        
    Sheets("Data - Accidents").Select
    Set NextRow = ActiveSheet.Cells(Cells.Rows.Count, 1).End(xlUp).Offset(1, 0)
    NextRow.Select
    Selection.PasteSpecial (xlValues), Transpose:=True

End Sub
I think you will have to copy the merged cell separately from the non-merged cell. You would do this to copy it...

Range("D6").MergeArea.Copy
 
Upvote 0
I think you will have to copy the merged cell separately from the non-merged cell. You would do this to copy it...

Range("D6").MergeArea.Copy


Thanks, that works, now for the rest of my code - I am trying to copy it all to the next line.

This code only copies the merged cell, not the value in V6. Any ideas?

Code:
Private Sub Data_to_Database()

 Application.ScreenUpdating = False


    Dim NextRow As Range
    
        Sheets("Entry - Accidents").Range("D6").Copy
    Sheets("Entry - Accidents").Range("M7").MergeArea.Copy
    
    Sheets("Data - Tempt").Select
    Set NextRow = ActiveSheet.Cells(Cells.Rows.Count, 1).End(xlUp).Offset(1, 0)
    NextRow.Select
    Selection.PasteSpecial (xlValues), Transpose:=True
    
    Application.CutCopyMode = False
    Application.ScreenUpdating = True


End Sub
 
Upvote 0
Thanks, that works, now for the rest of my code - I am trying to copy it all to the next line.

This code only copies the merged cell, not the value in D6. Any ideas?
The same idea that I gave you in Message #3 ... copy the non-merged cell separately from the merged cell. You already have the code for that... simply remove the V6 reference from it.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,174
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top