VBA Copy and Paste Macro doesnt line up correctly

LostInEverything

New Member
Joined
May 27, 2024
Messages
6
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. Mobile
Hi,

To begin with I'm quite new to excel VBA and trying to learn it as I go, so if anyone has good starting points or materials I would love to see them.

But onto my actual question. I am trying to make a spreadsheet that uses a macro to send info form specific cells in another sheet to a second. Now I have managed to make that happen, but the way I have to do it requires me to separate the copy and paste action. Therefore, I am encountering an issue where the data doesnt line up as I want it to.

It comes out like this:
1716790790566.png


When I need it to look like this:
1716791023637.png


This is the code I am using:

Sub Copy3()

If IsEmpty(Sheets("SourceSheet").Range("D2:D3").Value) Then
End
Else: Sheets("SourceSheet").Select
Range("D2:D3").Select
Selection.Copy
Sheets("TargetSheet").Select
Sheets("TargetSheet").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True

End If

If IsEmpty(Sheets("SourceSheet").Range("B7:C10").Value) Then
End
Else: Sheets("SourceSheet").Select
Range("B7:C10").Select
Selection.Copy
Sheets("TargetSheet").Select
Sheets("TargetSheet").Range("D" & Rows.Count).End(xlUp).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

End If

End Sub

If anyone knows a way to solve this, it would be greatly appreciated.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,224,813
Messages
6,181,115
Members
453,021
Latest member
Justyna P

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