Excel VBA copy/paste range

JessK

New Member
Joined
Apr 24, 2012
Messages
3
So I'm trying to make a macro to basically copy and paste imported information and make it look pretty in the excel sheet. The imported data can change all the time, so I'm using a lot of if thens. Heres an example of my imported data:
A B C D E F
Chicago 3 3 8 7 139977-002
Chicago 7 3 7 5
Chicago 20 3 3 1
Joliet 50 3 8 6 139978-003
Joliet 150 3 8 4
Wisconsin 20 3 8 5 1339980-001

Basically, what I need to do is when there is a number in column F, I need to copy and paste the values from Column B until there is another value in F, and then to do it again all the way to the end of the data. So that the only data I copy(the first time) is 3, 7, 20, and paste that in the proper place and then next 50, 150, to paste in a different place and then next 20.
Any ideas?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Its on a different worksheet. I'm pretty sure I know how to paste it after I copy the range, at least I can paste it to a cell -> .Copy Destination=Sheets("Bod") Cells("29,4")
 
Upvote 0
Code:
Sub FillIn()
Dim aCell As Range
Dim LastRow As Long
Dim DestRow As Long
DestRow = 29
LastRow = ActiveSheet.Range("A65536").End(xlUp).Row - 1
For Each aCell In ActiveSheet.Range("F1:F" & LastRow)
If aCell.Offset(0, 1) = "" Then
Worksheets("Bod").Cells(DestRow, 4) = aCell.Offset(0, -4).Value
DestRow = DestRow + 1
End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,076
Messages
6,128,669
Members
449,463
Latest member
Jojomen56

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