VBA code to copy and paste multiple times

MrsFraser07

New Member
Joined
Aug 16, 2017
Messages
44
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi there, I get an awful government report every month that I want to have a macro that will automatically copy and paste multiple times. The file looks like this when I get it:

License Number
License Status
UWI
Deemed Asset Value
Deemed Liability Amount
PVS Value
25393
Suspension
12-28-081-09W5
83956
Inactive
Type
Liability
Included in Cost
Deemed Liability Amount
Abandonment
WB Abandonment
Y
60081
Reclamation
Site Reclamation
Y
23875
28928
Issued
04-16-085-09W5
92614
Active
Type
Liability
Included in Cost
Deemed Liability Amount
Abandonment
Additional Event
Y
13748
Abandonment
WB Abandonment
Y
54991
Reclamation
Site Reclamation
Y
23875

<tbody>
</tbody>

What I would like my macro to do, is delete the blank rows (there are always 2 between each data set per license number), then copy the license number, then paste it in all the blank cells underneath it until it reaches the next unique license number. Then copy the new license number, paste into all blank rows beneath it, until it reaches the next, and so on. Hopefully that make sense? Any help would be most appreciated! My report currently has over 25,000 rows and I would hate to have to copy and paste them!

Thanks!
Shari
 
When I run the script from post #4 , it does fill in all the license numbers, but doesn't delete the rows. I get an error at Columns(1).SpecialCells(xlBlanks).EntireRow.Delete The error I get is Run-time error "1004': Method 'Range' of object'_Global' failed

To be honest, I really don't need those extra rows deleted, I just though it would be cleaner. The main thing was to populate the license number multiple times. I really appreciate your help! I'm good with formulas in excel, just trying to build my skills and get into some VBA!!!
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
When I run the script from post #4 , it does fill in all the license numbers, but doesn't delete the rows. I get an error at Columns(1).SpecialCells(xlBlanks).EntireRow.Delete The error I get is Run-time error "1004': Method 'Range' of object'_Global' failed

To be honest, I really don't need those extra rows deleted, I just though it would be cleaner. The main thing was to populate the license number multiple times. I really appreciate your help! I'm good with formulas in excel, just trying to build my skills and get into some VBA!!!
 
Upvote 0
Sorry for all the double posts! My computer (or this site) is super slow today and for some crazy reason my posts are being posted twice!!!
 
Upvote 0
Sorry for all the double posts! My computer (or this site) is super slow today and for some crazy reason my posts are being posted twice!!!
I think that there are ongoing problems with the site, since an upgrade as few weeks ago. If you are getting a pop-up asking if you want to leave the page, I've discovered that if you say no then the post will appear twice.
I get an error at Columns(1).SpecialCells(xlBlanks).EntireRow.Delete The error I get is Run-time error "1004': Method 'Range' of object'_Global' failed
I'm not quite sure why you're getting that error, but an alternative would be to remove it & the do a sort on column A
 
Upvote 0
Thanks for all your help Fluff!!! I took out that last line of code and it works beautifully now! All my license numbers get populated. The blank rows are not deleted, but I really don't care. I can always do a quick "Go To Special" and highlight all my blank rows and get rid of them that way. No issues if they stay in my sheet though. Again, I very much appreciate your help!!! You saved me from thousands of copy and paste operations!
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,943
Messages
6,127,820
Members
449,409
Latest member
katiecolorado

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