VBA to copy rows

overlord32

New Member
Joined
Sep 16, 2014
Messages
1
I am using excel 2013
I have this code I am using to copy rows based on a value in column W
columns A-V have the data I want to copy into the same sheet

The issue I am having is the data is not copying down to the next empty row. Nothing is happening. Any help is much appreciated

Public Sub CopyData()
' This routing will copy rows based on the quantity to a new sheet.
Dim rngSinglecell As Range
Dim rngQuantityCells As Range
Dim intCount As Integer


' Set this for the range where the Quantity column exists. This works only if there are no empty cells
Set rngQuantityCells = Range("W1", Range("W1").End(xlDown))


For Each rngSinglecell In rngQuantityCells
' Check if this cell actually contains a number
If IsNumeric(rngSinglecell.Value) Then
' Check if the number is greater than 0
If rngSinglecell.Value > 0 Then
' Copy this row as many times as .value
For intCount = 1 To rngSinglecell.Value
' Copy the row into the next emtpy row in Leones Resources
Range(rngSinglecell.Address).EntireRow.Copy -- This is not copying the rows
' Find the next empty row.
Sheets("Leones Resources").Range("A" & Rows.Count).End(xlUp).Offset (1)
Next
End If
End If
Next
End Sub
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Welcome to the Board!

I don't think the issue is with the line you have highlighted. You selected a row to Copy, but you do not have a corresponding Paste line anywhere.
Also, if "Leones Resources" the same sheet the data originally resides on, or a different one?
If different, what is the name of the sheet you are copying the data from?
 
Upvote 0

Forum statistics

Threads
1,225,071
Messages
6,182,683
Members
453,132
Latest member
nsnodgrass73

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