To paste data to another sheet by separating several columns

Kenor

Board Regular
Joined
Dec 8, 2020
Messages
116
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I need help me to edit below formula to copy & paste data from FG_SHIP sheet to SHIPMENT_DATA sheet but need to separate some column.
1. Copy data from column "A3:F" & paste to "A3:F".
2. Copy data from column "G3:G" & paste to "H3:H"

Sub RoundedRectangle3_Click()

Dim wsFG_SHIP As Worksheet
Dim wsSHIPMENT_DATA As Worksheet
Dim CopyLastRow As Long
Dim DestLastRow As Long

Set wsFG_SHIP = Worksheets("FG SHIP")
Set wsSHIPMENT_DATA = Worksheets("SHIPMENT_DATA")

CopyLastRow = wsFG_SHIP.Range("A" & wsFG_SHIP.Rows.Count).End(xlUp).Row + 1
DestLastRow = wsSHIPMENT_DATA.Range("A" & wsSHIPMENT_DATA.Rows.Count).End(xlUp).Row + 1

wsFG_SHIP.Range("A3", "L" & CopyLastRow).Copy Destination:=wsSHIPMENT_DATA.Range("A" & DestLastRow)
wsFG_SHIP.Range("A3", "A" & CopyLastRow).EntireRow.Delete

End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
VBA Code:
Option Explicit
Sub RoundedRectangle3_Click()
Dim wsFG_SHIP As Worksheet
Dim wsSHIPMENT_DATA As Worksheet
Dim CopyLastRow As Long
Dim DestLastRow As Long
Set wsFG_SHIP = Worksheets("FG_SHIP")' it was "FG SHIP" in your original code. Correct it to actual sheet name
Set wsSHIPMENT_DATA = Worksheets("SHIPMENT_DATA")
CopyLastRow = wsFG_SHIP.Range("A" & wsFG_SHIP.Rows.Count).End(xlUp).Row
DestLastRow = wsSHIPMENT_DATA.Range("A" & wsSHIPMENT_DATA.Rows.Count).End(xlUp).Row + 1
wsFG_SHIP.Range("A3:F" & CopyLastRow).Cut Destination:=wsSHIPMENT_DATA.Range("A" & DestLastRow)' cut = copy then delete initial range
wsFG_SHIP.Range("G3:G" & CopyLastRow).Cut Destination:=wsSHIPMENT_DATA.Range("H" & DestLastRow)' cut = copy then delete initial range
End Sub
 
Upvote 0
VBA Code:
Option Explicit
Sub RoundedRectangle3_Click()
Dim wsFG_SHIP As Worksheet
Dim wsSHIPMENT_DATA As Worksheet
Dim CopyLastRow As Long
Dim DestLastRow As Long
Set wsFG_SHIP = Worksheets("FG_SHIP")' it was "FG SHIP" in your original code. Correct it to actual sheet name
Set wsSHIPMENT_DATA = Worksheets("SHIPMENT_DATA")
CopyLastRow = wsFG_SHIP.Range("A" & wsFG_SHIP.Rows.Count).End(xlUp).Row
DestLastRow = wsSHIPMENT_DATA.Range("A" & wsSHIPMENT_DATA.Rows.Count).End(xlUp).Row + 1
wsFG_SHIP.Range("A3:F" & CopyLastRow).Cut Destination:=wsSHIPMENT_DATA.Range("A" & DestLastRow)' cut = copy then delete initial range
wsFG_SHIP.Range("G3:G" & CopyLastRow).Cut Destination:=wsSHIPMENT_DATA.Range("H" & DestLastRow)' cut = copy then delete initial range
End Sub
Thanks @bebo021999 for your help!
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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