Copy / Paste merged cells between worksheets

nc_4080

New Member
Joined
Aug 23, 2013
Messages
3
I have a code where i am highlighting a cell in a worksheet (Step 1 - Manifold), clicking a commandbutton, then the value that was highlighted copies over to another worksheet (Smart Calc).

It works great but the issue is that some of the cells that you highlight are merged. This means for instance that if the cell you selected was merged with 3 cells, the script thinks you are highlighting 3 cells and therefore copies the data 3 times to the other worksheet.

Is there a way that my code can work to only copy / paste the selected data once to the other worksheet?

Here is my code:




Private Sub CommandButton1_Click()
Dim c As Variant
Dim cValue As Variant
Dim test As Variant


Application.DisplayAlerts = False
Application.EnableEvents = False


For Each c In Selection.Cells
Worksheets("Step 1 - Manifold 8640").Activate
c.Activate
test = ActiveCell.Value


Worksheets("Smart Calc").Activate
Worksheets("Smart Calc").Range("A10").Select
Do While ActiveCell.Value <> ""
ActiveCell.Offset(1, 0).Select

Loop
ActiveCell.Value = test

Next


Application.DisplayAlerts = False
Application.EnableEvents = False


Worksheets("Step 1 - Manifold 8640").Activate
End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Range)


End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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