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
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