LostInEverything
New Member
- Joined
- May 27, 2024
- Messages
- 3
- Office Version
- 365
- 2021
- Platform
- Windows
- 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:
When I need it to look like this:
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.
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:
When I need it to look like this:
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.