VBA code require to copy paste data

Navi_G

Board Regular
Joined
May 30, 2018
Messages
94
Office Version
  1. 2016
Platform
  1. Windows
Dear All Experts,
I have a data which i want to copy paste in other sheet for which i make following VBA code but its not working plz provide help.
VBA Code:
VBA Code:
Sub Rangeo()

Dim r1 As Range

For y = 1 To 12
For x = y To 16 Step 4



    Set r1 = Range(Cells(1, y), Cells(11, x))
    r1.Select
Next x
Next y

Range("A1").Select
End Sub
Actual Data:
Line #PlanSAMQTYLine #PlanSAMQTYLine #PlanSAMQTY
11505415.215021506644110031507134555
115055461572150674615731507246157
115056448821506844883150734488
115057512772150695127731507451277
115058552554215070552554315075552554
115059444142150715541431507655414
115060144472150721444731507714447
115061417721507341773150784177
115062221452150742214531507922145
115063341442150753414431508034144
115064441442150764414431508144144
115065445521507744553150824455
Needed output:
Line #PlanSAMQTY
11505415.2150
11505546157
1150564488
11505751277
115058552554
11505944414
11506014447
1150614177
11506222145
11506334144
11506444144
1150654455
Line #PlanSAMQTY
215066441100
21506746157
2150684488
21506951277
215070552554
21507155414
21507214447
2150734177
21507422145
21507534144
21507644144
2150774455
Line #PlanSAMQTY
31507134555
31507246157
3150734488
31507451277
315075552554
31507655414
31507714447
3150784177
31507922145
31508034144
31508144144
3150824455
I have large files of this type of data given data is only a smaller piece.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
For me to help I need specific details in words.
You have showed us a script that does not work.
And two images of your data.
And no other details

I need something like this

Search column G of sheet named "Alpha" for "John" and when found copy that row to sheet named "Bravo"
 
Upvote 0
Are you Should have First row after end of each line No. or don't need it.
if you don't need it & First sheet name is Sheet1 & Other is Sheet2 Try this:
VBA Code:
Sub TransferData()
Dim i As Long, j As Long, Lr1 As Long, Lc1 As Long, Sh1 As Worksheet, Sh2 As Worksheet
Dim Lr2 As Long, Lc2 As Long
Set Sh1 = Sheets("Sheet1")
Set Sh2 = Sheets("Sheet2")
Lc1 = Sh1.Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To Lc1 Step 4
Lr1 = Sh1.Cells(Rows.Count, i).End(xlUp).Row
Lr2 = Sh2.Cells(Rows.Count, 1).End(xlUp).Row
If Lr2 = 1 Then
Sh2.Range("A1:D" & Lr1).Value = Range(Sh1.Cells(1, i), Sh1.Cells(Lr1, i + 3)).Value
Else
Sh2.Range("A" & Lr2 + 1 & ":D" & Lr2 + Lr1 - 1).Value = Range(Sh1.Cells(2, i), Sh1.Cells(Lr1, i + 3)).Value
End If
Next i
End Sub
 
Upvote 0
Are you Should have First row after end of each line No. or don't need it.
if you don't need it & First sheet name is Sheet1 & Other is Sheet2 Try this:
VBA Code:
Sub TransferData()
Dim i As Long, j As Long, Lr1 As Long, Lc1 As Long, Sh1 As Worksheet, Sh2 As Worksheet
Dim Lr2 As Long, Lc2 As Long
Set Sh1 = Sheets("Sheet1")
Set Sh2 = Sheets("Sheet2")
Lc1 = Sh1.Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To Lc1 Step 4
Lr1 = Sh1.Cells(Rows.Count, i).End(xlUp).Row
Lr2 = Sh2.Cells(Rows.Count, 1).End(xlUp).Row
If Lr2 = 1 Then
Sh2.Range("A1:D" & Lr1).Value = Range(Sh1.Cells(1, i), Sh1.Cells(Lr1, i + 3)).Value
Else
Sh2.Range("A" & Lr2 + 1 & ":D" & Lr2 + Lr1 - 1).Value = Range(Sh1.Cells(2, i), Sh1.Cells(Lr1, i + 3)).Value
End If
Next i
End Sub
Dear Sir,

may be u r missing source formatting please provide with source formatting code thanks.

Navi _ G
 
Upvote 0
Hi, as you forgot to well describe your source data address and the place of the expected result, could be easier with an attachment …​
 
Upvote 0
Hi, as you forgot to well describe your source data address and the place of the expected result, could be easier with an attachment …​
How Attach File tell me.
 
Upvote 0
What is Source formatting. I told if you want also row 1 for all transfer or not And you don't answer?
Upload your example file with XL2bb ADDIN (preferable) or upload at free hosting site e.g. www.dropbox.com or GoogleDrive or OneDrive and Insert Link here
 
Upvote 0

Forum statistics

Threads
1,214,886
Messages
6,122,093
Members
449,064
Latest member
Danger_SF

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