Skipping lines with data

krisbowls

New Member
Joined
Oct 18, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I've been trying to figure out a code to copy and paste a column of data from one sheet into another sheet. The hangup is that the paste-to sheet has data every other row that needs to be skipped.

So my very inefficient workaround is just to copy/paste it cell by cell. I'd rather paste it in groups. The copied data is all coming from column B in the "Received" sheet and it's being pasted into columns A through L on the "Traveler" sheet as shown below. Is there a better, faster, more efficient way of doing this?

Thanks,

VBA Code:
Worksheets("Traveler").Range("C2").Value = Worksheets("Received").Range("F2").Value
    Worksheets("Received").Range("B2").Value = Worksheets("Traveler").Range("A13").Value
    Worksheets("Received").Range("B3").Value = Worksheets("Traveler").Range("A15").Value
    Worksheets("Received").Range("B4").Value = Worksheets("Traveler").Range("A17").Value
    Worksheets("Received").Range("B5").Value = Worksheets("Traveler").Range("A19").Value
    Worksheets("Received").Range("B6").Value = Worksheets("Traveler").Range("A21").Value
    Worksheets("Received").Range("B7").Value = Worksheets("Traveler").Range("A23").Value
    Worksheets("Received").Range("B8").Value = Worksheets("Traveler").Range("B9").Value
    Worksheets("Received").Range("B9").Value = Worksheets("Traveler").Range("B11").Value
    Worksheets("Received").Range("B10").Value = Worksheets("Traveler").Range("B13").Value
    Worksheets("Received").Range("B11").Value = Worksheets("Traveler").Range("B15").Value
    Worksheets("Recieved").Range("B12").Value = Worksheets("Traveler").Range("B17").Value
    Worksheets("Received").Range("B13").Value = Worksheets("Traveler").Range("B19").Value
    Worksheets("Received").Range("B14").Value = Worksheets("Traveler").Range("B21").Value
    Worksheets("Received").Range("B15").Value = Worksheets("Traveler").Range("B23").Value

And the above code will just continue line by line until reaching cell L23.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I haven't tested this code, but I would expect something along this line would do the trick:

VBA Code:
Dim x As Integer
Dim y As Integer

Worksheets("Traveler").Range("C2").Value = Worksheets("Received").Range("F2").Value

y = 11
For x = 2 To 15
    Worksheets("Received").Range("B" & x).Value = Worksheets("Traveler").Range("A" & y + 2).Value
    y = y + 2
Next x
 
Upvote 0
Solution
I haven't tested this code, but I would expect something along this line would do the trick:

VBA Code:
Dim x As Integer
Dim y As Integer

Worksheets("Traveler").Range("C2").Value = Worksheets("Received").Range("F2").Value

y = 11
For x = 2 To 15
    Worksheets("Received").Range("B" & x).Value = Worksheets("Traveler").Range("A" & y + 2).Value
    y = y + 2
Next x

Thank you very much, with a little tweaking this is working great for me!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
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