Excel Jason
New Member
- Joined
- Oct 17, 2022
- Messages
- 30
- Office Version
- 365
- Platform
- Windows
Hello,
I have a macro that takes an item number and duplicates it 'x' amount of times based on a number is an adjacent cell. The macro works fine but I still receive this error once it completes it's run. "Run-time error '1004': Application-defined or object-defined error"
VBA Code:
Sub RepeatData()
'Repeat Rows
Dim XRg As Range
Dim InRg As Range, OutXRg As Range
'A Box Named Repeat Rows will Show
Set InRg = Range("B5:C120")
Set OutXRg = Range("H5")
Set OutXRg = OutXRg.Range("A1")
For Each XRg In InRg.Rows
xValue = XRg.Range("A1").Value
xNum = XRg.Range("B1").Value
OutXRg.Resize(xNum, 1).Value = xValue
Set OutXRg = OutXRg.Offset(xNum, 0)
Next
End Sub
Thank You!
I have a macro that takes an item number and duplicates it 'x' amount of times based on a number is an adjacent cell. The macro works fine but I still receive this error once it completes it's run. "Run-time error '1004': Application-defined or object-defined error"
VBA Code:
Sub RepeatData()
'Repeat Rows
Dim XRg As Range
Dim InRg As Range, OutXRg As Range
'A Box Named Repeat Rows will Show
Set InRg = Range("B5:C120")
Set OutXRg = Range("H5")
Set OutXRg = OutXRg.Range("A1")
For Each XRg In InRg.Rows
xValue = XRg.Range("A1").Value
xNum = XRg.Range("B1").Value
OutXRg.Resize(xNum, 1).Value = xValue
Set OutXRg = OutXRg.Offset(xNum, 0)
Next
End Sub
Thank You!